Skip to content

Commit

Permalink
[fix](nereids)EliminateGroupBy rule should keep output's datatype unc…
Browse files Browse the repository at this point in the history
…hanged
  • Loading branch information
starocean999 committed Dec 12, 2024
1 parent 947100f commit 9b87466
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.doris.nereids.trees.expressions.functions.agg.Min;
import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
import org.apache.doris.nereids.trees.expressions.functions.scalar.If;
import org.apache.doris.nereids.trees.expressions.literal.Literal;
import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.util.ExpressionUtils;
import org.apache.doris.nereids.util.PlanUtils;
Expand Down Expand Up @@ -84,12 +84,8 @@ public Rule build() {
.castIfNotSameType(f.child(0), f.getDataType()), ne.getName()));
} else if (f instanceof Count) {
newOutput.add((NamedExpression) ne.withChildren(
new If(
new IsNull(f.child(0)),
Literal.of(0),
Literal.of(1)
)
));
new If(new IsNull(f.child(0)), new BigIntLiteral(0),
new BigIntLiteral(1))));
} else {
throw new IllegalStateException("Unexpected aggregate function: " + f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void eliminateCount() {
logicalEmptyRelation().when(p -> p.getProjects().get(0).toSql().equals("id")
&& p.getProjects().get(1).toSql()
.equals("if(age IS NULL, 0, 1) AS `if(age IS NULL, 0, 1)`")
&& p.getProjects().get(1).getDataType().isBigIntType()
)
);
}
Expand Down

0 comments on commit 9b87466

Please sign in to comment.