mkleen opened a new issue, #26985:
URL: https://github.com/apache/datafusion/issues/26985

   ### Describe the bug
   
   `approx_distinct` gives an estimate of how many different values a column 
holds. It doesn't work on floating-point numbers. It returns a "not 
implemented" error. If you put the same numbers inside a list, or inside a 
struct or map, approx_distinct accepts them and returns a result.
   
   
   
   ### To Reproduce
   
   ```sql
   SELECT approx_distinct(arrow_cast(1.5, 'Float64'));
   -- Error: not implemented for Float64
   
   SELECT approx_distinct(make_array(1.5, 2.5));
   -- Works and returns a result
   ```
   
   This happens because the support check only looks at the outer type. For a 
list, it sees "list" and lets it through without checking what's inside. For 
dictionary-encoded and run-end-encoded columns it does look inside, which is 
why those are rejected correctly.
   
   
   
   ### Expected behavior
   
   Floats should be handled the same way whether they are on their own or 
inside a list. Either they work in both cases, or they fail in both cases:
   
   ```sql
   SELECT approx_distinct(make_array(1.5, 2.5));
   -- Error: not implemented for Float64
   ```
   
   Possible approach:
   
   Make the check look inside lists, structs and maps, and reject them if they 
contain decimal numbers. This is simpler, but queries that work today would 
start failing.
   
   
   
   
   
   ### Additional context
   
   - The check is in datafusion/functions-aggregate/src/approx_distinct.rs 
(is_supported_type and is_hll_groups_type).
   - Existing tests that expect the error are in 
datafusion/sqllogictest/test_files/aggregate.slt, around lines 1896–1903.
   
   ### Willingness to contribute
   
   None


-- 
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]

Reply via email to