feat: add lagInFrame/leadInFrame to WindowFuncKind, add Clickhouse window function catalog - #269
Merged
milindsrivastava1997 merged 1 commit intoAug 24, 2026
Conversation
…nts (#267) Mapping ClickHouse's frame-respecting lagInFrame/leadInFrame onto the existing Lag/Lead variants would silently ignore the window frame clause, since ANSI LAG/LEAD (and DataFusion's native lag/lead) are defined to ignore it entirely. Add distinct WindowFuncKind::LagInFrame/LeadInFrame variants instead, so the frame clause is never conflated away. DataFusion's planner rejects lagInFrame/leadInFrame outright as unknown functions -- unlike lag/lead, they need a stub WindowUDF registered (mirroring the existing CLICKHOUSE_BUILTINS/CLICKHOUSE_SCALAR_BUILTINS mechanism), so this adds a CLICKHOUSE_WINDOW_BUILTINS catalog table alongside them. WindowFuncKind still has no frame representation, so these lower and behave like plain Lag/Lead today -- the tag is correct, the frame-respecting behavior isn't modeled yet (#231). Updates the two pinned SQL-corpus tests (bgp_analytics, bgp_jan2024_workload) to reflect the new coverage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
milindsrivastava1997
marked this pull request as ready for review
August 24, 2026 01:01
zzylol
approved these changes
Aug 24, 2026
milindsrivastava1997
deleted the
267-laginframe-leadinframe-windowfunckind
branch
August 24, 2026 01:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LagInFrame/LeadInFramevariants toWindowFuncKindthat are specific to Clickhouse. These are distinct fromLag/Leadwhich are ANSI (Clickhouse's behavior is different from ANSI)CLICKHOUSE_WINDOW_BUILTINStable insql-function-catalog.WindowFuncKindstill has no frame representation (SQL: ClickHouse's lagInFrame window function needs window-frame modeling #231), so these lower and behave like plainLag/Leadtoday — the tag is correct, the frame-respecting behavior isn't modeled yet.bgp_analytics,bgp_jan2024_workload) to reflect the new coverage:bgp_analyticsquery 11 now lowers end to end; inbgp_jan2024_workload, 3 of the 6lagInFrameoccurrences now clear (the other 3 still fail on unrelated unregistered builtins —dateDiff,toString— out of scope here).Closes #267.
Test plan
cargo test --workspace— all greencargo clippy --workspace --all-targets— clean on affected crateslag_in_frame_lowers_to_its_own_kind_not_lag,lead_in_frame_lowers_to_its_own_kind_not_lead(sql_lowering.rs)CLICKHOUSE_WINDOW_BUILTINSlookup/lowercase/non-shadowing invariants🤖 Generated with Claude Code