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 step window functions for usability (delta/change etc.) #179

Open
davidkohn88 opened this issue Jul 14, 2021 · 0 comments
Open

Single step window functions for usability (delta/change etc.) #179

davidkohn88 opened this issue Jul 14, 2021 · 0 comments
Labels
feature-request And area of analysis that could be made easier

Comments

@davidkohn88
Copy link
Contributor

While the standard lead/lag window functions are very useful, they can be cumbersome to work with, for instance to get a delta I'd have to do something like:

SELECT lead(value) OVER (PARTITION BY id ORDER BY time) - value FROM foo

While that's okay, it gets a little confusing syntactically when you are doing lots of operations on windowed values as the window clauses tend to end up making the syntax a bit confusing, providing convenience functions like
SELECT delta(value) OVER (PARTITION BY id ORDER BY time) FROM foo would make them easier to work with in some situations.

List of possible additions as we think of them:
delta - difference between this value and next, possible optional parameter or different name for lead/lag (for all of these?)
change - boolean returning whether the value changed, possibly with a second optional parameter specifying the magnitude of the change
increase/decrease - similar to change except signed

@davidkohn88 davidkohn88 added the feature-request And area of analysis that could be made easier label Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request And area of analysis that could be made easier
Projects
None yet
Development

No branches or pull requests

1 participant