Skip to content

Plan nested window functions for Snowflake - #67

Merged
osipovartem merged 1 commit into
embucket-sync-df55.0.0from
snowflake-nested-window-planning
Sep 5, 2026
Merged

Plan nested window functions for Snowflake#67
osipovartem merged 1 commit into
embucket-sync-df55.0.0from
snowflake-nested-window-planning

Conversation

@osipovartem

Copy link
Copy Markdown
Collaborator

Summary

  • plan nested window functions in dependency order for the Snowflake SQL dialect
  • materialize each innermost window level before rebasing and planning its parent level
  • preserve the original SELECT expression names after staged planning
  • retain the existing nested-window planning error for Generic and PostgreSQL-compatible behavior

Why

Snowflake accepts expressions such as:

SELECT SUM(SUM(value) OVER ()) OVER ()

A single DataFusion Window node cannot execute nested window expressions. The Snowflake planner path now lowers them into consecutive Window nodes, while other dialects keep the existing validation behavior.

This also enables Rustice to execute Snowflake's documented pattern where CONDITIONAL_TRUE_EVENT consumes a LAG(...) OVER (...) expression.

Validation

  • cargo +1.97.0 test -p datafusion-sql --lib --tests (92 unit + 585 integration tests)
  • cargo +1.97.0 test -p datafusion --test core_integration snowflake_nested_window_functions_execute_in_stages
  • cargo +1.97.0 clippy -p datafusion-sql -p datafusion --lib --tests -- -D warnings
  • cargo +1.97.0 fmt --all -- --check

@osipovartem
osipovartem merged commit 0676b9c into embucket-sync-df55.0.0 Sep 5, 2026
37 checks passed
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