You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "beryllw (via GitHub)" <gi...@apache.org> on 2026/05/08 07:50:55 UTC
[I] [flink] COUNT(column) aggregate pushdown produces incorrect results for nullable columns [fluss]
beryllw opened a new issue, #3270:
URL: https://github.com/apache/fluss/issues/3270
### Search before asking
- [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.
### Fluss version
0.9.0 (latest release)
### Please describe the bug 🐞
### Problem
The current `applyAggregates` implementation in `FlinkTableSource` incorrectly pushes down `COUNT(column)` queries for nullable columns. When the aggregate function is `CountAggFunction` (which handles both `COUNT(*)` and `COUNT(column)`), it is always treated as equivalent to `COUNT(*)` and pushed down to return the total row count.
However, `COUNT(column)` should exclude NULL values from the count, whereas `COUNT(*)` counts all rows regardless of NULL values. This leads to incorrect query results when the column contains NULL values.
### Expected Behavior
- `COUNT(*)` and `COUNT(1)` should be pushed down (total row count).
- `COUNT(column)` on a **non-nullable** column should be pushed down (equivalent to `COUNT(*)`).
- `COUNT(column)` on a **nullable** column should NOT be pushed down, because the server-side row count includes rows with NULL values in that column.
### Current Behavior
All forms of COUNT are pushed down regardless of column nullability, producing incorrect results for `COUNT(nullable_column)`.
### Reproduction
```sql
-- Table with nullable 'address' column containing NULLs
SELECT COUNT(address) FROM my_table;
-- Returns total row count (e.g., 5) instead of non-null count (e.g., 3)
### Solution
_No response_
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
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: issues-unsubscribe@fluss.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [flink] COUNT(column) aggregate pushdown produces incorrect results for nullable columns [fluss]
Posted by "loserwang1024 (via GitHub)" <gi...@apache.org>.
loserwang1024 closed issue #3270: [flink] COUNT(column) aggregate pushdown produces incorrect results for nullable columns
URL: https://github.com/apache/fluss/issues/3270
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org