Skip to content

Support expression defaults in LEAD and LAG - #74

Merged
osipovartem merged 1 commit into
embucket-sync-df55.0.0from
window-lead-lag-expression-default
Sep 8, 2026
Merged

Support expression defaults in LEAD and LAG#74
osipovartem merged 1 commit into
embucket-sync-df55.0.0from
window-lead-lag-expression-default

Conversation

@osipovartem

Copy link
Copy Markdown
Collaborator

Which issue does this PR close?

Closes no issue.

Rationale for this change

LEAD and LAG currently reject a non-literal third argument even though SQL evaluates the default expression for the current row. This blocks Snowflake-compatible queries such as LAG(value, 1, id * 10).

What changes are included in this PR?

  • evaluate non-literal defaults as a per-row window input
  • preserve the existing scalar fast path for literal defaults
  • support both RESPECT NULLS and IGNORE NULLS
  • cast dynamic defaults to the result type
  • add focused unit and SQL logic tests

Are there any user-facing changes?

Yes. LEAD and LAG now accept expression defaults and evaluate them against the current row when the requested offset is outside the partition.

How was this tested?

  • cargo +1.95.0 test -p datafusion-functions-window
  • cargo +1.95.0 test -p datafusion-sqllogictest --test sqllogictests -- lead_lag_expression_default
  • cargo +1.95.0 clippy -p datafusion-functions-window --all-targets --all-features -- -D warnings
  • cargo +1.95.0 fmt --all -- --check

@osipovartem
osipovartem merged commit 7c75367 into embucket-sync-df55.0.0 Sep 8, 2026
16 checks passed
@osipovartem
osipovartem deleted the window-lead-lag-expression-default branch September 8, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant