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

Add SQL examples to window functions: nth_value, etc #13399

Open
jonathanc-n opened this issue Nov 13, 2024 · 3 comments
Open

Add SQL examples to window functions: nth_value, etc #13399

jonathanc-n opened this issue Nov 13, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jonathanc-n
Copy link
Contributor

jonathanc-n commented Nov 13, 2024

Is your feature request related to a problem or challenge?

Mentioned in #13395

Describe the solution you'd like

Add SQL examples to the window functions (nth_value, cumedist, etc.) through the dynamically created docs, an example of it can be found here: #13390

The window function docs are here: https://datafusion.apache.org/user-guide/sql/window_functions.html

The goal is to have SQL examples for each function

Describe alternatives you've considered

No response

Additional context

No response

@jonathanc-n jonathanc-n added the enhancement New feature or request label Nov 13, 2024
@jonathanc-n
Copy link
Contributor Author

@alamb This can also be given a good first issue label.

@alamb alamb added the good first issue Good for newcomers label Nov 14, 2024
@alamb alamb changed the title Add SQL examples to window functions Add SQL examples to window functions: nth_value, etc Nov 14, 2024
@alamb
Copy link
Contributor

alamb commented Nov 14, 2024

Thanks @jonathanc-n -- here are some notes to help anyone who wants to help with this:

What I normaly do is fire up datafusion-cli and copy/paste the result of the query into the code

So for example, to test cume_dist

https://datafusion.apache.org/user-guide/sql/window_functions.html#cume-dist

I would do

> SELECT x, cume_dist() OVER (ORDER BY y) as cume_dist FROM VALUES (1,20), (2, 10), (3,30) t(x,y);
+---+--------------------+
| x | cume_dist          |
+---+--------------------+
| 2 | 0.3333333333333333 |
| 1 | 0.6666666666666666 |
| 3 | 1.0                |
+---+--------------------+
3 row(s) fetched.
Elapsed 0.002 seconds.

BTW the syntax

VALUES (1,20), (2, 10), (3,30) t(x,y);

Basically creates a temporary table named t with columns x and y

@spencerscott917
Copy link

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants