Skip to content

OBSL-1027: SQL AST window functions + UNION-in-CTE#2776

Draft
mivds wants to merge 4 commits into
obsl-1025-extend-payload-builder-with-metrics-fieldfrom
obsl-1027-sql-ast-window-functions-and-cte-union
Draft

OBSL-1027: SQL AST window functions + UNION-in-CTE#2776
mivds wants to merge 4 commits into
obsl-1025-extend-payload-builder-with-metrics-fieldfrom
obsl-1027-sql-ast-window-functions-and-cte-union

Conversation

@mivds

@mivds mivds commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the SQL-AST primitives the v3 numeric profiler needs, unblocking the profiling SQL port (OBSL-1017). Scope was determined by the OBSL-1014 spike.

  • WINDOW_FUNCTION AST node (sql_ast.py) — name, args, optional partition_by: list[COLUMN], optional order_by (reuses ORDER_BY_ASC/ORDER_BY_DESC). Renders NAME(args) OVER ([PARTITION BY ...] [ORDER BY ...]).
  • UNION-in-CTE — widened CTE.cte_query to accept UNION (covers UNION_ALL); _build_cte renders it via build_union_sql.
  • Rendering reuses existing function-arg + ORDER BY logic; additive dispatch branch in build_expression_sql.

Rendered output examples (asserted in tests): ROW_NUMBER() OVER (ORDER BY "value_" DESC), SUM("amount") OVER (PARTITION BY "category" ORDER BY "id" ASC), CTE bodies containing UNION / UNION ALL.

Stacked on #2774 (OBSL-1025) → #2773 (OBSL-1013). Closes the AST gap from the OBSL-1014 spike.

Test Plan

  • 7 new unit tests asserting rendered SQL (window fns w/ partition+order, no-clause, multi-col partition, CTE UNION/UNION ALL)
  • Regression: soda-tests/tests/unit → 993 passed, 2 skipped, 0 failures
  • pre-commit (isort/black/autoflake) clean

🤖 Generated with Claude Code

…E (OBSL-1027)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mivds and others added 3 commits July 1, 2026 23:30
…to obsl-1027-sql-ast-window-functions-and-cte-union
…t (OBSL-1027)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…to obsl-1027-sql-ast-window-functions-and-cte-union
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant