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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to