github-actions[bot] commented on code in PR #63479:
URL: https://github.com/apache/doris/pull/63479#discussion_r3351667702
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java:
##########
@@ -92,13 +92,37 @@ public void checkLegalityBeforeTypeCoercion() {
public void checkLegalityAfterRewrite() {
// after rewrite, count(distinct bitmap_column) should be rewritten to
bitmap_union_count(bitmap_column)
for (Expression argument : getArguments()) {
- if (distinct && (argument.getDataType().isComplexType()
- || argument.getDataType().isObjectType() ||
argument.getDataType().isJsonType())) {
- throw new AnalysisException("COUNT DISTINCT could not process
type " + this.toSql());
+ if (distinct) {
+ checkDistinctArgument(argument, this);
Review Comment:
This check runs only in the final `CheckLegalityAfterRewrite` pass, but
`DistinctAggregateRewriter` runs earlier (`Rewriter` applies it before the
final expression legality checks). For grouped `COUNT(DISTINCT variant_expr)`,
if the planner chooses the split-distinct strategy, `splitDistinctAgg()`
rewrites the distinct `Count` away (`withDistinctAndChildren(false, ...)`) and
puts the distinct argument into the bottom aggregate's group-by keys. At that
point neither this `Count.checkDistinctArgument()` nor
`MultiDistinctCount.checkDistinctVariantArgument()` will see the original
VARIANT distinct argument, so the query can continue into the variant
group-key/hash path instead of producing the intended `AnalysisException`.
Please reject unsupported distinct arguments before `DistinctAggregateRewriter`
can split them, or make the split rewrite perform the same validation before it
removes the distinct aggregate. The current regression only covers the scalar
aggregate path, so it would
not catch this grouped rewrite bypass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]