Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -622,10 +623,19 @@ private Plan bindAggregate(MatchingContext<LogicalAggregate<Plan>> ctx) {
SimpleExprAnalyzer aggOutputAnalyzer = buildSimpleExprAnalyzer(
agg, cascadesContext, agg.children(), true, true);
List<NamedExpression> boundAggOutput = aggOutputAnalyzer.analyzeToList(agg.getOutputExpressions());
Supplier<Scope> aggOutputScopeWithoutAggFun = buildAggOutputScopeWithoutAggFun(boundAggOutput, cascadesContext);
List<NamedExpression> boundProjections = new ArrayList<>(boundAggOutput.size());
for (NamedExpression output : boundAggOutput) {
if (output instanceof BoundStar) {
boundProjections.addAll(((BoundStar) output).getSlots());
} else {
boundProjections.add(output);
}
}
Supplier<Scope> aggOutputScopeWithoutAggFun =
buildAggOutputScopeWithoutAggFun(boundProjections, cascadesContext);
List<Expression> boundGroupBy = bindGroupBy(
agg, agg.getGroupByExpressions(), boundAggOutput, aggOutputScopeWithoutAggFun, cascadesContext);
return agg.withGroupByAndOutput(boundGroupBy, boundAggOutput);
agg, agg.getGroupByExpressions(), boundProjections, aggOutputScopeWithoutAggFun, cascadesContext);
return agg.withGroupByAndOutput(boundGroupBy, boundProjections);
}

private Plan bindRepeat(MatchingContext<LogicalRepeat<Plan>> ctx) {
Expand Down
15 changes: 15 additions & 0 deletions regression-test/suites/nereids_p0/aggregate/agg_error_msg.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,19 @@ suite("agg_error_msg") {
sql """SELECT col_int_undef_signed2 col_alias1, col_int_undef_signed * (SELECT MAX (col_int_undef_signed) FROM table_20_undef_partitions2_keys3_properties4_distributed_by58 where table_20_undef_partitions2_keys3_properties4_distributed_by53.pk = pk) AS col_alias2 FROM table_20_undef_partitions2_keys3_properties4_distributed_by53 GROUP BY GROUPING SETS ((col_int_undef_signed2),()) ;"""
exception "pk, col_int_undef_signed not in aggregate's output";
}

test {
sql """SELECT * from table_20_undef_partitions2_keys3_properties4_distributed_by58 group by 1;"""
exception "col_int_undef_signed, col_int_undef_signed2 not in aggregate's output";
}

test {
sql """SELECT *, pk from table_20_undef_partitions2_keys3_properties4_distributed_by58 group by 1;"""
exception "col_int_undef_signed, col_int_undef_signed2 not in aggregate's output";
}

test {
sql """SELECT *, * from table_20_undef_partitions2_keys3_properties4_distributed_by58 group by 1;"""
exception "col_int_undef_signed, col_int_undef_signed2 not in aggregate's output";
}
}