-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check #31848
Changes from 2 commits
e1a9722
f65ebe3
776828e
6709185
b631350
9711da0
d782723
241e6e4
30d2d8b
0d38ac2
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 |
---|---|---|
|
@@ -24,8 +24,9 @@ import org.apache.hadoop.fs.Path | |
import org.apache.spark.internal.Logging | ||
import org.apache.spark.internal.config.IO_WARNING_LARGEFILETHRESHOLD | ||
import org.apache.spark.sql.{AnalysisException, SparkSession} | ||
import org.apache.spark.sql.catalyst.expressions.{Expression, ExpressionSet} | ||
import org.apache.spark.sql.catalyst.expressions.{AttributeSet, Expression, ExpressionSet} | ||
import org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection | ||
import org.apache.spark.sql.catalyst.plans.QueryPlan | ||
import org.apache.spark.sql.connector.read.{Batch, InputPartition, Scan, Statistics, SupportsReportStatistics} | ||
import org.apache.spark.sql.execution.PartitionedFileUtil | ||
import org.apache.spark.sql.execution.datasources._ | ||
|
@@ -84,11 +85,24 @@ trait FileScan extends Scan | |
|
||
protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]") | ||
|
||
private lazy val (normalizedPartitionFilters, normalizedDataFilters) = { | ||
val output = readSchema().toAttributes | ||
val partitionFilterAttributes = AttributeSet(partitionFilters).map(a => a.name -> a).toMap | ||
val dataFiltersAttributes = AttributeSet(dataFilters).map(a => a.name -> a).toMap | ||
val normalizedPartitionFilters = ExpressionSet(partitionFilters.map( | ||
QueryPlan.normalizeExpressions(_, output.map(a => | ||
partitionFilterAttributes.getOrElse(a.name, a))))) | ||
val normalizedDataFilters = ExpressionSet(dataFilters.map( | ||
QueryPlan.normalizeExpressions(_, output.map(a => | ||
dataFiltersAttributes.getOrElse(a.name, a))))) | ||
(normalizedPartitionFilters, normalizedDataFilters) | ||
} | ||
|
||
override def equals(obj: Any): Boolean = obj match { | ||
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. Shall I update 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. Shall we do that separately because it's irrelevant to the correctness issue? 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. Please file a new JIRA and go for it, @peter-toth ! :) |
||
case f: FileScan => | ||
fileIndex == f.fileIndex && readSchema == f.readSchema | ||
ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) && | ||
ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters) | ||
fileIndex == f.fileIndex && readSchema == f.readSchema && | ||
normalizedPartitionFilters == f.normalizedPartitionFilters && | ||
normalizedDataFilters == f.normalizedDataFilters | ||
|
||
case _ => false | ||
} | ||
|
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.
shall we consider case sensitivity here?
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.
or the attr name inside the
data/partitionFilterAttributes
have been normalized already before?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.
I think we shall, added in 776828e