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

Improve doc for Window functions #18507

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

weiatwork
Copy link
Contributor

@weiatwork weiatwork commented Aug 3, 2023

Description

The doc should make it clear that the ORDER BY clause in an aggregate function is not supported, if the aggregate function is used as a window function.

For example, this works:

SELECT ARRAY_AGG(phone) OVER (PARTITION BY custkey) FROM customer

while this one fails:

SELECT ARRAY_AGG(phone ORDER BY phone) OVER (PARTITION BY custkey) FROM customer

line 1:59: PARTITION BY expression 'custkey' must be an aggregate expression or appear in GROUP BY clause

Additional context and related issues

Release notes

(x) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

@cla-bot cla-bot bot added the cla-signed label Aug 3, 2023
@weiatwork weiatwork requested a review from mosabua August 3, 2023 00:30
@github-actions github-actions bot added the docs label Aug 3, 2023
@mosabua
Copy link
Member

mosabua commented Aug 3, 2023

In your example you have an ORDER BY as part of the parameter for the array_agg function. The docs for the array_agg function clearly indicate that you just pass in a parameter .. not a statement snippet.

The error message you see is probably misleading but this doc change is incorrect from all I can tell. Wdyt @kasiafi ?

@weiatwork
Copy link
Contributor Author

Do you mean this by docs for array_agg? Yes, this doc may also need to be updated to describe the additional usage, as detailed here. It's not a statement snippet per se, but a special clause supported by array_agg.

@mosabua mosabua force-pushed the doc-window-aggregate branch from ea3aa7a to 94e08fc Compare November 20, 2023 22:26
@mosabua mosabua force-pushed the doc-window-aggregate branch from 94e08fc to 59fe33e Compare November 20, 2023 22:27
Copy link
Member

@mosabua mosabua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good after a minor tweak. Thank you and sorry for the delay.

@mosabua mosabua merged commit ed54241 into trinodb:master Nov 20, 2023
2 checks passed
@github-actions github-actions bot added this to the 434 milestone Nov 20, 2023
@weiatwork weiatwork deleted the doc-window-aggregate branch November 20, 2023 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants