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

DISTINCT is not implemented for window functions #4545

Closed
2 tasks done
drorspei opened this issue Aug 31, 2022 · 4 comments
Closed
2 tasks done

DISTINCT is not implemented for window functions #4545

drorspei opened this issue Aug 31, 2022 · 4 comments
Assignees

Comments

@drorspei
Copy link
Contributor

What happens?

Count distinct over windows is not currently supported. For example:

select count(distinct a) over(partition by b) from c

Prints the error "DISTINCT is not implemented for window functions."

The lack of support starts in the parser and is inherited from the pg code.

If I wanted to work on this, where would I start?
Do you think this is a reasonable thing to try to implement? (given your knowledge and preferences, as well as the fact that postgres never did (and as far as I can tell neither did presto, Spark or mssql))

To Reproduce

select count(distinct a) over(partition by b) from c

OS:

Linux

DuckDB Version:

0.4.1.dev2358

DuckDB Client:

Python

Full Name:

Dror Speiser

Affiliation:

None

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree
@hawkfish
Copy link
Contributor

Thanks for the report! This is a big can of worms that is on my radar for later this year. I wouldn't recommend wading in because the architecture will changing underneath you for out of core operations, but hey, its open source!

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@hawkfish
Copy link
Contributor

A lot of the necessary refactoring has been done, so we are getting closer.

@hawkfish
Copy link
Contributor

hawkfish commented Oct 4, 2023

I think I have a working merge sort tree now (which was less work than I feared) so progress continues to be made.

@hawkfish hawkfish self-assigned this Oct 4, 2023
hawkfish added a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Compile basic WindowDistinctAggregator build steps.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Import and compile aggregation method.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Refactor EXCLUDE "part" machinery for reuse.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Compile first back end implementation.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Add parser support. Not hooked up yet.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Change refactoring base to custom aggregator
and back out previous refactor.
Add missing finalisation.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Debug algorithm 1 implementation.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Basic COUNT(DISTINCT) working.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Add basic naive accelerator triggered by the window debug "separate" setting.
Still needs distinct.
hawkfish added a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Add and test naive distinct aggregation.
hawkfish added a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Test naïve DISTINCT + EXCLUDE combination.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Add scaling tests.
Divert DISTINCT EXCLUDE to the naive implementation.
hawkfish pushed a commit to hawkfish/duckdb that referenced this issue Nov 21, 2023
Improve EXCLUDE DISTINCT test to actually do something.
hawkfish added a commit to hawkfish/duckdb that referenced this issue Dec 7, 2023
hawkfish added a commit to hawkfish/duckdb that referenced this issue Dec 9, 2023
hawkfish added a commit to hawkfish/duckdb that referenced this issue Dec 9, 2023
Mark's PR Feedback:
Force naïve implementation when the optimiser is disabled.
hawkfish added a commit to hawkfish/duckdb that referenced this issue Dec 9, 2023
Mark's PR Feedback: Coverage tests, fix FILTER.
hawkfish added a commit to hawkfish/duckdb that referenced this issue Dec 9, 2023
Only fix FILTER when filtering.
hawkfish added a commit to hawkfish/duckdb that referenced this issue Dec 9, 2023
Don't dispose of radix data when merging.
hawkfish added a commit to hawkfish/duckdb that referenced this issue Dec 9, 2023
Call aggregate destructors for distinct tree nodes
to avoid memory leaks.
Mytherin added a commit that referenced this issue Dec 19, 2023
Issue #4545: Windowed Distinct Aggregates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants