NGA-TRAN opened a new issue, #8175:
URL: https://github.com/apache/arrow-datafusion/issues/8175

   ### Describe the bug
   
   After IOx upgraded DF recently, we hit a bug in count distinct with 
`date_bin`/`date_part`.  
   
   
   
   ### To Reproduce
   
   After some investigation, here is the reproducer in Datafusion CLI:
   
   ```SQL
   create table t1(state string, city string, min_temp float, area int, time 
timestamp) as values 
       ('MA', 'Boston', 70.4, 1, 50),
       ('MA', 'Bedford', 71.59, 2, 150);
   
   select date_part('year', time) as bla, count(distinct state) as count from 
t1 group by bla;
   -- Optimizer rule 'single_distinct_aggregation_to_group_by' failed caused by 
Schema error: No field named "date_part(Utf8(""year""),t1.time)". Valid fields 
are group_alias_0, "COUNT(DISTINCT t1.state)".
   
   -- this query has the same issue
   select date_bin(interval '1 year', time) as bla, count(distinct state) as 
count from t1 group by bla;
   ```
   
   ### Expected behavior
   
   The queries should work
   
   ### Additional context
   
   After I backed out 
https://github.com/apache/arrow-datafusion/commit/15d8c9bf48a56ae9de34d18becab13fd1942dc4a
 locally, the queries work


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