Skip to content

Commit c4ef321

Browse files
johanl-dbyaooqinn
authored andcommitted
[SPARK-48308][CORE][3.5] Unify getting data schema without partition columns in FileSourceStrategy
### What changes were proposed in this pull request? (Cherry-pick of 57948c8 to branch-3.5) Compute the schema of the data without partition columns only once in FileSourceStrategy. ### Why are the changes needed? In FileSourceStrategy, the schema of the data excluding partition columns is computed 2 times in a slightly different way, using an AttributeSet (`partitionSet`) and using the attributes directly (`partitionColumns`) These don't have the exact same semantics, AttributeSet will only use expression ids for comparison while comparing with the actual attributes will use the name, type, nullability and metadata. We want to use the former here. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing tests ### Was this patch authored or co-authored using generative AI tooling? No Authored-by: Johan Lasperas <johan.lasperasdatabricks.com> Closes #47483 from vkorukanti/partitionCols. Authored-by: Johan Lasperas <[email protected]> Signed-off-by: Kent Yao <[email protected]>
1 parent 66b7cb9 commit c4ef321

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,8 @@ object FileSourceStrategy extends Strategy with PredicateHelper with Logging {
210210
val requiredExpressions: Seq[NamedExpression] = filterAttributes.toSeq ++ projects
211211
val requiredAttributes = AttributeSet(requiredExpressions)
212212

213-
val readDataColumns = dataColumns
213+
val readDataColumns = dataColumnsWithoutPartitionCols
214214
.filter(requiredAttributes.contains)
215-
.filterNot(partitionColumns.contains)
216215

217216
// Metadata attributes are part of a column of type struct up to this point. Here we extract
218217
// this column from the schema and specify a matcher for that.

0 commit comments

Comments
 (0)