[GLUTEN-12597][CORE] Migrate WindowRel to ConsistentPartitionWindowRel + BoundsType (Substrait 0.98) - #12727
Open
nielspardon wants to merge 1 commit into
Open
Conversation
…l + BoundsType (Substrait 0.98)
Migrate the windowing message family from the vendored Substrait v0.23.0
fork to official 0.98.0, with the JVM producer and both native consumers
moved in lockstep so round-trip correctness is preserved:
- WindowRel -> ConsistentPartitionWindowRel; the Measure{WindowFunction}
wrapper is repacked into a bare WindowRelFunction. Gluten already hoists
partition_expressions/sorts to the rel level and never set per-function
partitions/sorts, which is exactly the ConsistentPartitionWindowRel
invariant, so this is a field-subset repack, not a semantic change.
- Expression.WindowFunction.WindowType (field 13; ROWS=0, RANGE=1) ->
nested BoundsType (field 12; BOUNDS_TYPE_UNSPECIFIED=0, ROWS=1, RANGE=2).
Every value shifts by one; the producer maps via the named constants.
- Bound: unbounded_preceding/unbounded_following collapse into a single
`unbounded`; direction is inferred from position (lower_bound = start,
upper_bound = end).
Kept Gluten grafts: the RANGE `ref` bound consumed by Velox
PreComputeRangeFrameBound, and per-function `column_name` on
WindowRelFunction (0.98 has none).
Touches the proto, WindowFunctionNode/WindowRelNode (producer), Velox
SubstraitToVeloxPlan + Validator, ClickHouse WindowRelParser +
AggregateFunctionParser, the q47 static test plan, and a new
WindowRelProtoSuite round-trip test that pins the enum value remap and the
unbounded-bound collapse.
Part of apache#12597
Generated-by: Claude Code (Claude Opus 4.8)
|
Run Gluten Clickhouse CI on x86 |
nielspardon
marked this pull request as ready for review
August 7, 2026 20:57
19 tasks
JkSelf
approved these changes
Aug 12, 2026
JkSelf
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thanks for your work.
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.
What changes were proposed in this pull request?
Part of #12597 (rebase the vendored Substrait proto from v0.23.0 to 0.98.0). This PR migrates the windowing message family to official Substrait 0.98.0, moving the JVM producer and both native consumers in lockstep. Because Gluten's plans are transient and producer + consumers regenerate from one proto source and ship together, there is no wire-compatibility constraint — only round-trip correctness matters.
Three coupled proto changes:
WindowRel→ConsistentPartitionWindowRel. TheMeasure { Expression.WindowFunction measure = 1 }wrapper is repacked into a bareWindowRelFunction. Gluten already hoistspartition_expressions/sortsto the rel level and never populated per-function partitions/sorts — exactly theConsistentPartitionWindowRelinvariant — so this is a field-subset repack, not a semantic change.WindowType→BoundsType(silent value remap). Fork: top-levelenum WindowType { ROWS = 0; RANGE = 1; }atExpression.WindowFunction.window_type = 13. 0.98: nestedenum BoundsType { BOUNDS_TYPE_UNSPECIFIED = 0; BOUNDS_TYPE_ROWS = 1; BOUNDS_TYPE_RANGE = 2; }atbounds_type = 12. Every value shifts by one; the producer maps via the named constants (not raw ordinals).Boundunbounded collapse.unbounded_preceding/unbounded_followingcollapse into a singleunbounded; direction is inferred from position (alower_bound= start of partition, anupper_bound= end).Two Gluten grafts are kept: the RANGE
refbound (oneof { int64 offset = 1; Expression ref = 2; }) consumed by VeloxPreComputeRangeFrameBound, and per-functioncolumn_namegrafted ontoWindowRelFunction(0.98 has none). The Rel oneof keepswindow = 16(only the field's type changes); whole-oneof renumbering is deferred to the reconciliation increment.Files: the vendored
algebra.proto;WindowFunctionNode/WindowRelNode(producer); VeloxSubstraitToVeloxPlan+SubstraitToVeloxPlanValidator; ClickHouseWindowRelParser+AggregateFunctionParser; thetpcds-q47-wholestage-9.jsonstatic test plan; and a newWindowRelProtoSuite.How was this patch tested?
WindowRelProtoSuite(gluten-substrait) — a producer round-trip that pins the two silent risks a plain compile can't catch: it asserts the frame-type enum value remap (BOUNDS_TYPE_ROWS.getNumber == 1,BOUNDS_TYPE_RANGE.getNumber == 2) and theunboundedcollapse at both the lower and upper bound positions, plus thecolumn_namegraft.GlutenClickHouseTPCDSMetricsSuite(via the updatedtpcds-q47-wholestage-9.jsonstatic plan, whose window operator metrics would break on a wrong frame/direction) and the Velox / gluten-ut window suites (VeloxWindowExpressionSuite,GlutenDataFrameWindowFramesSuite) which run unbounded/ROWS/RANGE frames end-to-end.gluten-substraitbuilds andWindowRelProtoSuitepasses; the Velox native backend compiles againstbounds_type/Unbounded/WindowRelFunction. The ClickHouse native backend is covered by CI.Generated-by: Claude Code (Claude Opus 4.8)
🤖 Generated with AI