[fix](nereids) fix bug when grouping has same grouping set (#32235)

This commit is contained in:
feiniaofeiafei
2024-03-15 14:25:52 +08:00
committed by yiguolei
parent afa9f6e5d6
commit 9e014cfb8a
5 changed files with 61 additions and 14 deletions

View File

@ -228,11 +228,18 @@ public interface Repeat<CHILD_PLAN extends Plan> extends Aggregate<CHILD_PLAN> {
this.shapes = ImmutableList.copyOf(shapes);
}
// compute a long value that backend need to fill to the GROUPING_ID slot
/**compute a long value that backend need to fill to the GROUPING_ID slot*/
public List<Long> computeVirtualGroupingIdValue() {
return shapes.stream()
.map(GroupingSetShape::computeLongValue)
.collect(ImmutableList.toImmutableList());
Set<Long> res = Sets.newLinkedHashSet();
long k = (long) Math.pow(2, flattenGroupingSetExpression.size());
for (GroupingSetShape shape : shapes) {
Long val = shape.computeLongValue();
while (res.contains(val)) {
val += k;
}
res.add(val);
}
return ImmutableList.copyOf(res);
}
public int indexOf(Expression expression) {