fix(isthmus)!: preserve grouping-set indices through Calcite conversion - #1287
Open
alexandrefimov wants to merge 1 commit into
Open
fix(isthmus)!: preserve grouping-set indices through Calcite conversion#1287alexandrefimov wants to merge 1 commit into
alexandrefimov wants to merge 1 commit into
Conversation
Substrait defines the grouping-set index as the zero-based position in the declared set list, with type i32 ([spec v0.102.0](https://github.com/substrait-io/substrait/blob/v0.102.0/site/docs/relations/logical_relations.md#aggregate-operation)). Calcite's GROUP_ID returns zero for distinct sets, and its normalized set order can change which set an index identifies after a round trip. Build the index from grouping-key membership and the occurrence of duplicate sets. For declared sets (b), (a), (b), the corresponding rows retain indices 0, 1, and 2. Calcite may keep its normalized set order; a projection preserves the index visible to parent relations. Translate SQL GROUPING/GROUPING_ID through Substrait's implicit index so these values also survive conversion back to Substrait. Calcite 1.42.0 still has an execution limitation with mixed empty and non-empty grouping sets on empty input: a row for an empty set can be lost. The same failure occurs with a Calcite-only plan. Closes substrait-io#1182 Closes substrait-io#1209 BREAKING CHANGE: The grouping-set index produced by Substrait-to-Calcite conversion now has INTEGER (i32) type instead of BIGINT. Callers that assume a BIGINT output column must use the i32 schema declared by Substrait.
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.
Substrait defines the grouping-set index as the zero-based position in the declared set list, with type i32 (spec v0.102.0). Calcite's GROUP_ID returns zero for distinct sets, and its normalized set order can change which set an index identifies after a round trip.
Build the index from grouping-key membership and the occurrence of duplicate sets. For declared sets (b), (a), (b), the corresponding rows retain indices 0, 1, and 2. Calcite may keep its normalized set order; a projection preserves the index visible to parent relations. Translate SQL GROUPING/GROUPING_ID through Substrait's implicit index so these values also survive conversion back to Substrait.
Calcite 1.42.0 still has an execution limitation with mixed empty and non-empty grouping sets on empty input: a row for an empty set can be lost. The same failure occurs with a Calcite-only plan.
Closes #1182
Closes #1209
BREAKING CHANGE: The grouping-set index produced by Substrait-to-Calcite conversion now has INTEGER (i32) type instead of BIGINT. Callers that assume a BIGINT output column must use the i32 schema declared by Substrait.