Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Count distinct with date_part/date_bin does not work #8175

Closed
NGA-TRAN opened this issue Nov 14, 2023 · 2 comments · Fixed by #8176
Closed

Regression: Count distinct with date_part/date_bin does not work #8175

NGA-TRAN opened this issue Nov 14, 2023 · 2 comments · Fixed by #8176
Labels
bug Something isn't working

Comments

@NGA-TRAN
Copy link
Contributor

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:

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 15d8c9b locally, the queries work

@NGA-TRAN NGA-TRAN added the bug Something isn't working label Nov 14, 2023
@NGA-TRAN
Copy link
Contributor Author

CC @alamb @haohuaijin

@NGA-TRAN
Copy link
Contributor Author

I am working on 2 PRs:

  1. Reverting 15d8c9b
  2. Adding above tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant