Uh oh!
There was an error while loading. Please reload this page.
[SPARK-50615][SQL] Push variant into scan. - #49235
Closed
chenhao-db wants to merge 2 commits into
Closed
Conversation
chenhao-db
commented
Dec 18, 2024
ContributorAuthor
@cloud-fan@gene-db@cashmand Please help review, thanks! |
| Batch("User Provided Optimizers", fixedPoint, experimentalMethods.extraOptimizations: _*), | ||
| Batch("Replace CTE with Repartition", Once, ReplaceCTERefWithRepartition))) | ||
| Batch("Replace CTE with Repartition", Once, ReplaceCTERefWithRepartition), | ||
| Batch("Push Variant Into Scan", Once, PushVariantIntoScan))) |
Contributor
There was a problem hiding this comment.
why does this rule need to be in the end of optimizer?
Comment on lines
+146
to
+147
| def addVariantFields(attrId: ExprId, dataType: DataType, defaultValue: Any, | ||
| path: Seq[Int]): Unit = { |
Contributor
There was a problem hiding this comment.
Suggested change
| defaddVariantFields(attrId: ExprId, dataType: DataType, defaultValue: Any, | |
| path: Seq[Int]):Unit= { | |
| defaddVariantFields( | |
| attrId: ExprId, | |
| dataType: DataType, | |
| defaultValue: Any, | |
| path: Seq[Int]):Unit= { |
Comment on lines
+198
to
+199
| private def addField(map: HashMap[RequestedVariantField, Int], | ||
| field: RequestedVariantField): Unit = { |
Contributor
There was a problem hiding this comment.
Suggested change
| privatedefaddField(map: HashMap[RequestedVariantField, Int], | |
| field: RequestedVariantField):Unit= { | |
| privatedefaddField( | |
| map: HashMap[RequestedVariantField, Int], | |
| field: RequestedVariantField):Unit= { |
| } | ||
| } | ||
| private def rewritePlan(originalPlan: LogicalPlan, |
Contributor
There was a problem hiding this comment.
ditto, fix indentaiton please
| // - Filter [v.0 = 1] | ||
| // - Relation [v: struct<0: int, 1: string, 2: variant>] | ||
| // The struct fields are annotated with `VariantMetadata` to indicate the extraction path. | ||
| object PushVariantIntoScan extends Rule[LogicalPlan] { |
Contributor
There was a problem hiding this comment.
This rule matches a similar plan pattern as SchemaPruning, shall we also put this rule in the earlyScanPushDownRules of SparkOptimizer?
chenhao-db
commented
Dec 20, 2024
ContributorAuthor
@cloud-fan Thanks! I have made the changes you recommended. |
cloud-fan
commented
Dec 20, 2024
Contributor
thanks, merging to master! |
cloud-fan pushed a commit
that referenced
this pull request
Dec 24, 2024
### What changes were proposed in this pull request? It adds support for variant struct in Parquet reader. The concept of variant struct was introduced in #49235. It includes all the extracted fields from a variant column that the query requests. ### Why are the changes needed? By producing variant struct in Parquet reader, we can avoid reading/rebuilding the full variant and achieve more efficient variant processing. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Unit test. ### Was this patch authored or co-authored using generative AI tooling? No. Closes#49263 from chenhao-db/spark_variant_struct_reader. Authored-by: Chenhao Li <chenhao.li@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
It adds an optimizer rule to push variant into scan by rewriting the variant type with a struct type producing all requested fields and rewriting the variant extraction expressions by struct accesses. This will be the foundation of the variant shredding reader. The rule must be disabled at this point because the scan part is not yet able to recognize the special struct.
Why are the changes needed?
It is necessary for the performance of reading from shredded variant. With this rule (and the reader implemented), the scan only needs to fetch the necessary shredded columns required by the plan.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test.
Was this patch authored or co-authored using generative AI tooling?
No.