-
Notifications
You must be signed in to change notification settings - Fork 173
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 Redshift lag and lead functions without the default parameter #549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please also add a bullet to the top of NEWS.md
? It should briefly describe the change and end with (@yourname, #issuenumber)
.
R/backend-redshift.R
Outdated
sql_translator(.parent = postgres$window) | ||
sql_translator(.parent = postgres$window, | ||
# https://docs.aws.amazon.com/redshift/latest/dg/r_WF_LAG.html | ||
lag = function(x, n = 1L, default = NA, order_by = NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be simpler if you just omitted the default
argument all together — then the user will just get the regular unused argument (default = 1)
error
expect_equal(translate_sql(lead(x)), sql("LEAD(`x`, 1) OVER ()")) | ||
expect_equal(translate_sql(lag(x)), sql("LAG(`x`, 1) OVER ()")) | ||
|
||
expect_error(translate_sql(lead(x, default = y)), "Redshift does not support") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also need to be updated
Hi @hadley, just did the changes you suggested. |
Thank you! |
Fixes #548
This pull request removes the
default
argument from the LAG and LEAD SQL functions. Redshift assumes that thedefault
parameter is NULL, therefore, we added an error in case that the user gives an alternative value fordefault
.Here is a reprex for the same code in #548 but with the fix applied:
Created on 2020-11-26 by the reprex package (v0.3.0)
And if the user gives a
default
value other than NA:Created on 2020-11-26 by the reprex package (v0.3.0)