Skip to content

Commit dfc8d54

Browse files
committed
fix: review comments
Signed-off-by: MBWhite <[email protected]>
1 parent 8c0af54 commit dfc8d54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

isthmus/src/main/java/io/substrait/isthmus/PreCalciteAggregateValidator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ private static boolean isValidCalciteGrouping(Aggregate.Grouping grouping) {
6868
return false;
6969
}
7070

71+
// Calcite stores grouping fields in an ImmutableBitSet and does not track the order of the
72+
// grouping fields. The output record shape that Calcite generates ALWAYS has the groupings in
73+
// ascending field order. This causes issues with Substrait in cases where the grouping fields
74+
// in Substrait are not defined in ascending order.
75+
76+
// For example, if a grouping is defined as (0, 2, 1) in Substrait, Calcite will output it as
77+
// (0, 1, 2), which means that the Calcite output will no longer line up with the expectations
78+
// of the Substrait plan.
79+
7180
List<Integer> groupingFields =
7281
grouping.getExpressions().stream()
7382
.map(expr -> getFieldRefOffset((FieldReference) expr))

0 commit comments

Comments
 (0)