-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-33482][SQL] Fix FileScan canonicalization #31820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
99c1482
c0fb9b2
20624d1
52cc2ca
483686d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ import org.apache.spark.sql.execution.datasources.{LogicalRelation, SchemaColumn | |
import org.apache.spark.sql.execution.datasources.v2.BatchScanExec | ||
import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan | ||
import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan | ||
import org.apache.spark.sql.execution.exchange.ReusedExchangeExec | ||
import org.apache.spark.sql.execution.joins.{BroadcastHashJoinExec, CartesianProductExec, SortMergeJoinExec} | ||
import org.apache.spark.sql.functions._ | ||
import org.apache.spark.sql.internal.SQLConf | ||
|
@@ -4065,6 +4066,29 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark | |
} | ||
} | ||
} | ||
|
||
test("SPARK-33482: Fix FileScan canonicalization") { | ||
withSQLConf(SQLConf.USE_V1_SOURCE_LIST.key -> "") { | ||
withTempPath { path => | ||
spark.range(5).toDF().write.mode("overwrite").parquet(path.toString) | ||
withTempView("t") { | ||
spark.read.parquet(path.toString).createOrReplaceTempView("t") | ||
val df = sql( | ||
""" | ||
|SELECT * | ||
|FROM t AS t1 | ||
|JOIN t AS t2 ON t2.id = t1.id | ||
|JOIN t AS t3 ON t3.id = t2.id | ||
|""".stripMargin) | ||
df.collect() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we do need to run the query first and then check the plan as this is an AQE compatible query where |
||
val reusedExchanges = collect(df.queryExecution.executedPlan) { | ||
case r: ReusedExchangeExec => r | ||
} | ||
assert(reusedExchanges.size == 1) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
case class Foo(bar: Option[String]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but is a bit hacky as it doesn't apply to all the
Scan
implementations.I think we should add doc in the
Scan
interface to explain how thehashCode/equals
should be implemented.