Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ private[sql] object FileSourceStrategy extends Strategy with Logging {
partitions
}

// These metadata values make scan plans uniquely identifiable for equality checking.
val meta = Map(
"PartitionFilters" -> partitionKeyFilters.mkString("[", ", ", "]"),
"Format" -> files.fileFormat.toString,
"ReadSchema" -> prunedDataSchema.simpleString,
PUSHED_FILTERS -> pushedDownFilters.mkString("[", ", ", "]"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.{Expression, ExpressionSet, PredicateHelper}
import org.apache.spark.sql.catalyst.util
import org.apache.spark.sql.execution.DataSourceScanExec
import org.apache.spark.sql.execution.{DataSourceScanExec, SparkPlan}
import org.apache.spark.sql.functions._
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.sources._
Expand Down Expand Up @@ -407,6 +407,39 @@ class FileSourceStrategySuite extends QueryTest with SharedSQLContext with Predi
}
}

test("[SPARK-16818] partition pruned file scans implement sameResult correctly") {
withTempPath { path =>
val tempDir = path.getCanonicalPath
spark.range(100)
.selectExpr("id", "id as b")
.write
.partitionBy("id")
.parquet(tempDir)
val df = spark.read.parquet(tempDir)
def getPlan(df: DataFrame): SparkPlan = {
df.queryExecution.executedPlan
}
assert(getPlan(df.where("id = 2")).sameResult(getPlan(df.where("id = 2"))))
assert(!getPlan(df.where("id = 2")).sameResult(getPlan(df.where("id = 3"))))
}
}

test("[SPARK-16818] exchange reuse respects differences in partition pruning") {
spark.conf.set("spark.sql.exchange.reuse", true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah actually just realized we could've improved with by using "withSQLConf" -- it makes sure the configs get reset after the test case finishes running.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I assumed the test already did so since I've seen this pattern
elsewhere. If it affects more than just the suite, I can submit a follow-up
fix.

On Sat, Jul 30, 2016, 10:59 PM Reynold Xin notifications@github.com wrote:

In
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategySuite.scala
#14427 (comment):

  •  spark.range(100)
    
  •    .selectExpr("id", "id as b")
    
  •    .write
    
  •    .partitionBy("id")
    
  •    .parquet(tempDir)
    
  •  val df = spark.read.parquet(tempDir)
    
  •  def getPlan(df: DataFrame): SparkPlan = {
    
  •    df.queryExecution.executedPlan
    
  •  }
    
  •  assert(getPlan(df.where("id = 2")).sameResult(getPlan(df.where("id = 2"))))
    
  •  assert(!getPlan(df.where("id = 2")).sameResult(getPlan(df.where("id = 3"))))
    
  • }
  • }
  • test("[SPARK-16818] exchange reuse respects differences in partition pruning") {
  • spark.conf.set("spark.sql.exchange.reuse", true)

ah actually just realized we could've improved with by using "withSQLConf"
-- it makes sure the configs get reset after the test case finishes running.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/apache/spark/pull/14427/files/ef60367331fb3097040cfb0849bdc314c8d399ea#r72898521,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAA6Sun3Ai6lEtCs9dcjaxlAtO3Y_a2Qks5qbDnQgaJpZM4JY91Z
.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i think those places were not correctly using the confs either.

withTempPath { path =>
val tempDir = path.getCanonicalPath
spark.range(10)
.selectExpr("id % 2 as a", "id % 3 as b", "id as c")
.write
.partitionBy("a")
.parquet(tempDir)
val df = spark.read.parquet(tempDir)
val df1 = df.where("a = 0").groupBy("b").agg("c" -> "sum")
val df2 = df.where("a = 1").groupBy("b").agg("c" -> "sum")
checkAnswer(df1.join(df2, "b"), Row(0, 6, 12) :: Row(1, 4, 8) :: Row(2, 10, 5) :: Nil)
}
}

// Helpers for checking the arguments passed to the FileFormat.

protected val checkPartitionSchema =
Expand Down