Skip to content

feat: back-port inline window-function grammar (OVER (PARTITION BY … ORDER BY …)) from t-rust-db/db-core parser::row #701

Description

@iheitlager

Description

t-rust-db/db-core's parser::row is a port of this crate's src/parser, and per t-rust-db/db-core ADR 0005 this grammar is the canonical one. The port has since grown a feature this crate lacks (t-rust-db/db-core#74/#67): inline window functions.

  • ast::Expr::FunctionCall { …, over: Option<WindowDef> }, WindowDef { partition_by: Vec<Expr>, order_by: Vec<OrderingTerm> } with Display
  • grammar.rs: OVER ( [PARTITION BY expr, …] [ORDER BY term, …] ) parsed; OVER <name>, frame clauses (ROWS/RANGE/GROUPS) and FILTER (…) stay Unsupported with specific messages
  • Tests: window_function_over_partition_and_order_by_roundtrips, window_over_named_window_reference_is_unsupported, window_frame_clause_is_unsupported, window_filter_clause_is_unsupported

Back-port it here so diff -r sqlite-rs/src/parser db-core/src/parser/row returns to zero (t-rust-db/db-core#84 records the rule: grammar changes land here first, or are back-ported in the same window). tests/unit/parser.rs line ~677 currently asserts OVER is unsupported and needs to follow. The codegen/VDBE side is a separate matter (spec 009 V9) — this ticket is grammar + AST + printer only; the planner may keep rejecting over for now.

Complexity

Estimate: small — ~150 lines, all already written in db-core; port verbatim.

Acceptance Criteria

  • src/parser/{ast,grammar,printer}.rs match db-core's parser::row for the window-function parts
  • The four db-core tests pass here; tests/unit/parser.rs's OVER expectation updated
  • make check-grammar-drift green (sqlite.ebnf gains the over_clause/window_defn rules with parse.y citations, per the grammar convention)

🤖 Analysis by Claude

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions