yujun777 opened a new pull request, #62548:
URL: https://github.com/apache/doris/pull/62548
### What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
`Count.isCountStar()` returns `true` for `count(null)` because it only
checks `child(0) instanceof Literal` without excluding `NullLiteral`. Since
`count(null)` always returns 0 (it counts non-null values of a constant null),
it is semantically different from `count(*)` which counts all rows.
This could cause incorrect results if downstream rewrite rules (e.g.
`PushDownAggThroughJoin`, `SimplifyWindowExpression`, `PushCountIntoUnionAll`)
use `isCountStar()` before `CountLiteralRewrite` has a chance to rewrite
`count(null)` to `0`.
### Release note
Fixed `count(null)` being incorrectly treated as `count(*)` in query
optimizer, which could lead to wrong results in certain rewrite scenarios.
### Check List (For Author)
- Test: Unit Test / Regression test
- FE UT: `CountLiteralRewriteTest` (3 tests pass, including new
`testCountNullIsNotCountStar`)
- Regression test: `count_null_not_count_star` covering basic, group by,
mixed, union all, window, and join paths
- Behavior changed: No
- Does this need documentation: No
--
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]