Skip to content

Commit e28168f

Browse files
committed
fix: adding support for both deprecated and new proto of Groupings for the AggregateRel
1 parent 3ee086c commit e28168f

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

core/src/main/java/io/substrait/relation/ProtoRelConverter.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -627,38 +627,38 @@ protected Aggregate newAggregate(AggregateRel rel) {
627627

628628
List<Aggregate.Grouping> groupings = new ArrayList<>(rel.getGroupingsCount());
629629

630-
// the deprecated form of Grouping is not used
631-
if (!rel.getGroupingExpressionsList().isEmpty()) {
632-
List<io.substrait.proto.Expression> allGroupingKeys = rel.getGroupingExpressionsList();
633-
634-
// for every grouping object on aggregate, it has a list of references into the aggregate's expressionList for the specific sorting set
635-
for (AggregateRel.Grouping grouping : rel.getGroupingsList()) {
636-
List<io.substrait.proto.Expression> groupingKeys = new ArrayList<>();
637-
for (int key: grouping.getExpressionReferencesList()) {
638-
groupingKeys.add(allGroupingKeys.get(key));
639-
}
640-
groupings.add(
641-
Aggregate.Grouping.builder()
642-
.expressions(
643-
groupingKeys.stream()
644-
.map(protoExprConverter::from)
645-
.collect(Collectors.toList()))
646-
.build());
647-
}
648-
Aggregate.builder().input(input).groupings(groupings);
649-
}else{
650-
// using the deprecated form of Grouping and Aggregate
651-
for (AggregateRel.Grouping grouping : rel.getGroupingsList()) {
652-
groupings.add(
653-
Aggregate.Grouping.builder()
654-
.expressions(
655-
grouping.getGroupingExpressionsList().stream()
656-
.map(protoExprConverter::from)
657-
.collect(Collectors.toList()))
658-
.build());
659-
}
630+
// the deprecated form of Grouping is not used
631+
if (!rel.getGroupingExpressionsList().isEmpty()) {
632+
List<io.substrait.proto.Expression> allGroupingKeys = rel.getGroupingExpressionsList();
633+
634+
// for every grouping object on aggregate, it has a list of references into the
635+
// aggregate's expressionList for the specific sorting set
636+
for (AggregateRel.Grouping grouping : rel.getGroupingsList()) {
637+
List<io.substrait.proto.Expression> groupingKeys = new ArrayList<>();
638+
for (int key : grouping.getExpressionReferencesList()) {
639+
groupingKeys.add(allGroupingKeys.get(key));
640+
}
641+
groupings.add(
642+
Aggregate.Grouping.builder()
643+
.expressions(
644+
groupingKeys.stream()
645+
.map(protoExprConverter::from)
646+
.collect(Collectors.toList()))
647+
.build());
660648
}
661-
649+
Aggregate.builder().input(input).groupings(groupings);
650+
} else {
651+
// using the deprecated form of Grouping and Aggregate
652+
for (AggregateRel.Grouping grouping : rel.getGroupingsList()) {
653+
groupings.add(
654+
Aggregate.Grouping.builder()
655+
.expressions(
656+
grouping.getGroupingExpressionsList().stream()
657+
.map(protoExprConverter::from)
658+
.collect(Collectors.toList()))
659+
.build());
660+
}
661+
}
662662

663663
List<Aggregate.Measure> measures = new ArrayList<>(rel.getMeasuresCount());
664664
for (AggregateRel.Measure measure : rel.getMeasuresList()) {

0 commit comments

Comments
 (0)