Fix cast wrapped AggregateUDF during Substrait Conversion#20679
Draft
hareshkh wants to merge 1 commit intoapache:mainfrom
Draft
Fix cast wrapped AggregateUDF during Substrait Conversion#20679hareshkh wants to merge 1 commit intoapache:mainfrom
hareshkh wants to merge 1 commit intoapache:mainfrom
Conversation
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 free
to 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.
Which issue does this PR close?
Rationale for this change
When the Substrait consumer applies root-level schema renames that involve struct field renames inside an aggregate measure's return type (e.g.
List<Struct{c0,c1}>→List<Struct{one,two}>),rename_expressionsinjectsExpr::Castaround the aggregate function. The physical planner rejects Cast-wrapped aggregates, causing a planning error.What changes are included in this PR?
from_substrait_plan_with_consumerinto a dedicatedapply_renamesfunction inplan.rs.alias_expressionsutility inutils.rsthat applies only top-level column name aliases without injectingExpr::Cast, making it safe for aggregate expressions.Aggregaterename strategy: first apply alias-only renames viaalias_expressions; if the schema still doesn't match (e.g. nested struct field renames require casts), wrap the Aggregate in a Projection that carries those casts.aggregate_with_struct_field_rename) that constructs a Substrait plan witharray_aggreturningList<Struct{c0,c1}>and root names that rename the struct fields tooneandtwo, verifying the consumer produces a valid plan that the physical planner accepts.Are these changes tested?
Yes. A new test case
aggregate_with_struct_field_renameinaggregation_tests.rsbuilds a Substrait plan with a struct field rename on an aggregate measure and verifies that:DataFrame::show()).Are there any user-facing changes?
No. This is a bug fix in the Substrait consumer that corrects plan generation for aggregate expressions with nested struct field renames. There are no API changes.