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

single_distinct_aggregation_to_group_by Failed due to generate a different schema with multiple distinct aggregates #7987

Closed
alamb opened this issue Oct 30, 2023 · 1 comment · Fixed by #7997
Labels
bug Something isn't working

Comments

@alamb
Copy link
Contributor

alamb commented Oct 30, 2023

Describe the bug

Running a query like this

select sum(distinct x), max(distinct x) from t group by x;

Generates an internal error:

caused by
single_distinct_aggregation_to_group_by
caused by
Internal error: Failed due to generate a different schema

To Reproduce

❯ create table t(x int) as values (1), (2), (1);
❯ select sum(distinct x), max(distinct x) from t group by x;
Optimizer rule 'single_distinct_aggregation_to_group_by' failed
caused by
single_distinct_aggregation_to_group_by
caused by
Internal error: Failed due to generate a different schema, original schema: DFSchema { fields: [DFField { qualifier: None, field: Field { name: "SUM(DISTINCT t.x)", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, DFField { qualifier: None, field: Field { name: "MAX(DISTINCT t.x)", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }], metadata: {}, functional_dependencies: FunctionalDependencies { deps: [] } }, new schema: DFSchema { fields: [DFField { qualifier: None, field: Field { name: "SUM(DISTINCT t.x)", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, DFField { qualifier: None, field: Field { name: "MAX(DISTINCT t.x)", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }], metadata: {}, functional_dependencies: FunctionalDependencies { deps: [] } }.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

### Expected behavior

query should run

### Additional context

Found while looking at https://github.com/apache/arrow-datafusion/issues/7938
@alamb alamb added the bug Something isn't working label Oct 30, 2023
@haohuaijin
Copy link
Contributor

I plan to fix it.

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.

2 participants