Skip to content

Commit c48a180

Browse files
committed
fix(isthmus): fix tpcds query 67
1 parent 9c0248a commit c48a180

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,24 @@ public abstract class Aggregate extends SingleInputRel implements HasExtension {
2121

2222
@Override
2323
protected Type.Struct deriveRecordType() {
24-
return TypeCreator.REQUIRED.struct(
25-
Stream.concat(
26-
// unique grouping expressions
27-
getGroupings().stream()
28-
.flatMap(g -> g.getExpressions().stream())
29-
.collect(Collectors.toCollection(LinkedHashSet::new))
30-
.stream()
31-
.map(Expression::getType),
24+
boolean isGroupingSet = getGroupings().size() > 1;
3225

33-
// measures
34-
getMeasures().stream().map(t -> t.getFunction().getType())));
26+
Stream<Type> groupingTypes =
27+
getGroupings().stream()
28+
.flatMap(g -> g.getExpressions().stream())
29+
.collect(Collectors.toCollection(LinkedHashSet::new))
30+
.stream()
31+
.map(
32+
expr -> {
33+
if (isGroupingSet) {
34+
return TypeCreator.asNullable(expr.getType());
35+
}
36+
return expr.getType();
37+
});
38+
39+
Stream<Type> measureTypes = getMeasures().stream().map(t -> t.getFunction().getType());
40+
41+
return TypeCreator.REQUIRED.struct(Stream.concat(groupingTypes, measureTypes));
3542
}
3643

3744
@Override

isthmus/src/test/java/io/substrait/isthmus/TpcdsQueryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public class TpcdsQueryTest extends PlanTestBase {
1616
private static final Set<Integer> toSubstraitExclusions = Set.of(9, 27, 36, 70, 86);
1717
private static final Set<Integer> fromSubstraitPojoExclusions = Set.of(1, 30, 81);
18-
private static final Set<Integer> fromSubstraitProtoExclusions = Set.of(1, 30, 67, 81);
18+
private static final Set<Integer> fromSubstraitProtoExclusions = Set.of(1, 30, 81);
1919

2020
static IntStream testCases() {
2121
return IntStream.rangeClosed(1, 99).filter(n -> !toSubstraitExclusions.contains(n));

0 commit comments

Comments
 (0)