-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40918][SQL] Mismatch between FileSourceScanExec and Orc and ParquetFileFormat on producing columnar output #38397
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
918c65b
SPARK-40918
juliuszsompolski d805162
fix compile
juliuszsompolski 6b851c2
unused import
juliuszsompolski 4e6729e
test name
juliuszsompolski ab83b1c
also for ORC
juliuszsompolski d3ff82d
missing newline at end of file
juliuszsompolski 4fc51e7
unused import
juliuszsompolski e36bdee
read orc as orc
juliuszsompolski e6211fc
space
juliuszsompolski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,6 @@ import org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjectio | |
| import org.apache.spark.sql.catalyst.parser.LegacyTypeStringParser | ||
| import org.apache.spark.sql.catalyst.util.DateTimeUtils | ||
| import org.apache.spark.sql.errors.QueryExecutionErrors | ||
| import org.apache.spark.sql.execution.WholeStageCodegenExec | ||
| import org.apache.spark.sql.execution.datasources._ | ||
| import org.apache.spark.sql.execution.vectorized.{ConstantColumnVector, OffHeapColumnVector, OnHeapColumnVector} | ||
| import org.apache.spark.sql.internal.SQLConf | ||
|
|
@@ -82,12 +81,11 @@ class ParquetFileFormat | |
| } | ||
|
|
||
| /** | ||
| * Returns whether the reader will return the rows as batch or not. | ||
| * Returns whether the reader can return the rows as batch or not. | ||
| */ | ||
| override def supportBatch(sparkSession: SparkSession, schema: StructType): Boolean = { | ||
| val conf = sparkSession.sessionState.conf | ||
| ParquetUtils.isBatchReadSupportedForSchema(conf, schema) && conf.wholeStageEnabled && | ||
| !WholeStageCodegenExec.isTooManyFields(conf, schema) | ||
| ParquetUtils.isBatchReadSupportedForSchema(conf, schema) | ||
| } | ||
|
|
||
| override def vectorTypes( | ||
|
|
@@ -110,6 +108,18 @@ class ParquetFileFormat | |
| true | ||
| } | ||
|
|
||
| /** | ||
| * Build the reader. | ||
| * | ||
| * @note It is required to pass FileFormat.OPTION_RETURNING_BATCH in options, to indicate whether | ||
| * the reader should return row or columnar output. | ||
| * If the caller can handle both, pass | ||
| * FileFormat.OPTION_RETURNING_BATCH -> | ||
| * supportBatch(sparkSession, | ||
| * StructType(requiredSchema.fields ++ partitionSchema.fields)) | ||
| * as the option. | ||
| * It should be set to "true" only if this reader can support it. | ||
| */ | ||
| override def buildReaderWithPartitionValues( | ||
| sparkSession: SparkSession, | ||
| dataSchema: StructType, | ||
|
|
@@ -161,8 +171,6 @@ class ParquetFileFormat | |
| val timestampConversion: Boolean = sqlConf.isParquetINT96TimestampConversion | ||
| val capacity = sqlConf.parquetVectorizedReaderBatchSize | ||
| val enableParquetFilterPushDown: Boolean = sqlConf.parquetFilterPushDown | ||
| // Whole stage codegen (PhysicalRDD) is able to deal with batches directly | ||
| val returningBatch = supportBatch(sparkSession, resultSchema) | ||
| val pushDownDate = sqlConf.parquetFilterPushDownDate | ||
| val pushDownTimestamp = sqlConf.parquetFilterPushDownTimestamp | ||
| val pushDownDecimal = sqlConf.parquetFilterPushDownDecimal | ||
|
|
@@ -173,6 +181,22 @@ class ParquetFileFormat | |
| val datetimeRebaseModeInRead = parquetOptions.datetimeRebaseModeInRead | ||
| val int96RebaseModeInRead = parquetOptions.int96RebaseModeInRead | ||
|
|
||
| // Should always be set by FileSourceScanExec creating this. | ||
| // Check conf before checking option, to allow working around an issue by changing conf. | ||
| val returningBatch = sparkSession.sessionState.conf.parquetVectorizedReaderEnabled && | ||
| options.get(FileFormat.OPTION_RETURNING_BATCH) | ||
| .getOrElse { | ||
| throw new IllegalArgumentException( | ||
| "OPTION_RETURNING_BATCH should always be set for ParquetFileFormat." + | ||
|
||
| "To workaround this issue, set spark.sql.parquet.enableVectorizedReader=false.") | ||
| } | ||
| .equals("true") | ||
| if (returningBatch) { | ||
| // If the passed option said that we are to return batches, we need to also be able to | ||
| // do this based on config and resultSchema. | ||
| assert(supportBatch(sparkSession, resultSchema)) | ||
| } | ||
|
|
||
| (file: PartitionedFile) => { | ||
| assert(file.partitionValues.numFields == partitionSchema.size) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.