hrbrmstr / sergeant

:guardsman: Tools to Transform and Query Data with 'Apache' 'Drill'
https://hrbrmstr.github.io/sergeant/
Other
126 stars 13 forks source link

Fix SQL translation for `lag()` and `lead()` #45

Open alistaire47 opened 3 years ago

alistaire47 commented 3 years ago

Hi!

Just a quick PR so Drill doesn't error out when using lead() or lag() with dbplyr SQL translation. Before this, the value for default (NA by default) would get passed in as a third argument (e.g. LAG(variable1, 1, NA)) which causes Drill to throw an error that refers users to this Jira ticket.

This implementation does pass through the value for n, which is 1L by default. Drill doesn't currently support any other value besides 1, but this implementation works and will be forwards-compatible if the limitation gets lifted in the future.