Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions core/src/main/java/io/substrait/relation/ProtoRelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,15 +626,40 @@ protected Aggregate newAggregate(AggregateRel rel) {
new ProtoAggregateFunctionConverter(lookup, extensions, protoExprConverter);

List<Aggregate.Grouping> groupings = new ArrayList<>(rel.getGroupingsCount());
for (AggregateRel.Grouping grouping : rel.getGroupingsList()) {
groupings.add(
Aggregate.Grouping.builder()
.expressions(
grouping.getGroupingExpressionsList().stream()
.map(protoExprConverter::from)
.collect(java.util.stream.Collectors.toList()))
.build());

// the deprecated form of Grouping is not used
if (!rel.getGroupingExpressionsList().isEmpty()) {
List<io.substrait.proto.Expression> allGroupingKeys = rel.getGroupingExpressionsList();
Comment thread
gord02 marked this conversation as resolved.
Outdated

// for every grouping object on aggregate, it has a list of references into the
// aggregate's expressionList for the specific sorting set
for (AggregateRel.Grouping grouping : rel.getGroupingsList()) {
List<io.substrait.proto.Expression> groupingKeys = new ArrayList<>();
for (int key : grouping.getExpressionReferencesList()) {
groupingKeys.add(allGroupingKeys.get(key));
}
groupings.add(
Aggregate.Grouping.builder()
.expressions(
groupingKeys.stream()
.map(protoExprConverter::from)
.collect(Collectors.toList()))
.build());
}
Aggregate.builder().input(input).groupings(groupings);
} else {
// using the deprecated form of Grouping and Aggregate
Comment thread
gord02 marked this conversation as resolved.
Outdated
for (AggregateRel.Grouping grouping : rel.getGroupingsList()) {
groupings.add(
Aggregate.Grouping.builder()
.expressions(
grouping.getGroupingExpressionsList().stream()
.map(protoExprConverter::from)
.collect(Collectors.toList()))
Comment thread
gord02 marked this conversation as resolved.
Outdated
.build());
}
}

List<Aggregate.Measure> measures = new ArrayList<>(rel.getMeasuresCount());
for (AggregateRel.Measure measure : rel.getMeasuresList()) {
measures.add(
Expand Down
Loading