Allow Offset parameter for LEAD and LAG window functions as input parameters
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by tracing Apache Drill's existing LEAD and LAG window-function implementation and how it parses their arguments. Compare the current behavior with the documented lag(expr, offset, default) syntax and the computed-column examples in the issue. Done means parameterized offsets work for LEAD and LAG, including lagging computed expressions without producing unexpected nulls.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
For time-series analysis, I would like to be able to lag columns for more than one position offset. currently the Lag function is restricted to an offset of '1' and does not allow it to be parameterized.
using Lag() on a computed column generates nulls.
Describe the solution you'd like
Ideally aligning to the following syntax
lag(expr[, offset[, default]][ IGNORE NULLS])
Returns expr evaluated at the row that is offset rows before the current row within the window frame;
https://duckdb.org/docs/sql/functions/window_functions.html#lagexpr-offset-default-ignore-nulls
Lag() on a computed column should provide the previous value of the expression outcome
`
'tickpos (Last*)' as 'tickpos (Last*)-0t',
LAG('tickpos (Last*)',1) OVER ( PARTITION BY tickpos_instrument_id, tickpos_granularity ORDER BY tickpos_unixtime_upper )
as 'tickpos (Last*)-1t',
LAG('tickpos (Last*)-1t',1) OVER ( PARTITION BY tickpos_instrument_id, tickpos_granularity ORDER BY tickpos_unixtime_upper )
as 'tickpos (Last*)-2t',
`
Describe alternatives you've considered
- lagging a lag computed column (this provides nulls)
- calculating the unix epoch time of lag time slices and self-joining based on that calculated timestamp
- potentially (but not tried) taking the first() element of a time window frame, ordered by timestamp
Additional context
- Dominant language
- Java
- Stars
- 2k
- Forks
- 989
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 7
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/drill
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
apache/drill#3014 · 11 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 28/100
apache/drill#3013 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
bancolombia/scaffold-clean-architecture#1002 ·
Maintainers usually reply within 1 day
-
CalendarEventAttendance/get returns eventAttendanceStatus while the doc says attendanceStatusPossibly taken @chibenwa claimed this today. Openbug claude
Difficulty 1/5 Under an hour Newbie friendliness 90/100
linagora/tmail-backend#2697 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/skywalking#14120 ·
Maintainers usually reply within 1 day
-
[BUG] Case-insensitive search suggestions miss items when the JVM default locale is TurkishPossibly taken @thswlsqls claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
HMCL-dev/HMCL#6943 · 1 comment ·
Maintainers usually reply within 1 day