Skip to content

Add window function (OVER clause) and CTE (WITH clause) execution lay…#593

Closed
jeffreyaven wants to merge 6 commits intomainfrom
claude/add-window-cte-execution-014D8D74PYhwWz83dLVpKV8v
Closed

Add window function (OVER clause) and CTE (WITH clause) execution lay…#593
jeffreyaven wants to merge 6 commits intomainfrom
claude/add-window-cte-execution-014D8D74PYhwWz83dLVpKV8v

Conversation

@jeffreyaven
Copy link
Member

…er support

  • Update go.mod with replace directive for new parser commit (1595204710ca) which includes window function and CTE parsing support
  • Add window function handling in parser_util.go: functions with OVER clause are now marked as IsAggregateExpr = true
  • Add CTE support in ast_expand.go:
    • Added cteRegistry field to track registered CTEs
    • Process CTEs in SELECT statements before other elements
    • CTE references in FROM clause skip provider/view lookup
  • Add tests for window functions (ROW_NUMBER, SUM, RANK, etc.)
  • Add tests for CTE parsing and registry functionality

Description

Type of change

  • Bug fix (non-breaking change to fix a bug).
  • Feature (non-breaking change to add functionality).
  • Breaking change.
  • Other (eg: documentation change). Please explain.

Issues referenced.

Evidence

Checklist:

  • A full round of testing has been completed, and there are no test failures as a result of these changes.
  • The changes are covered with functional and/or integration robot testing.
  • The changes work on all supported platforms.
  • Unit tests pass locally, as per the developer guide.
  • Robot tests pass locally, as per the developer guide.
  • Linter passes locally, as per the developer guide.

Variations

Tech Debt

…er support

- Update go.mod with replace directive for new parser commit (1595204710ca)
  which includes window function and CTE parsing support
- Add window function handling in parser_util.go: functions with OVER
  clause are now marked as IsAggregateExpr = true
- Add CTE support in ast_expand.go:
  - Added cteRegistry field to track registered CTEs
  - Process CTEs in SELECT statements before other elements
  - CTE references in FROM clause skip provider/view lookup
- Add tests for window functions (ROW_NUMBER, SUM, RANK, etc.)
- Add tests for CTE parsing and registry functionality
The replace directive for the new parser version requires go.sum
to be updated with the new dependency hashes. Adding go mod tidy
before running golangci-lint ensures the dependencies are resolved.
- Add window function test queries (ROW_NUMBER, RANK, SUM with OVER clause)
- Add CTE test queries (simple, with aggregation, multiple CTEs)
- Add expected output files for all test cases
- Add integration tests using mocked Google Compute Disks provider

Test coverage:
- Window ROW_NUMBER() OVER (ORDER BY name)
- Window RANK() OVER (ORDER BY sizeGb)
- Window SUM() OVER (ORDER BY name) for running totals
- Simple CTE with SELECT from CTE
- CTE with COUNT(*) aggregation
- Multiple CTEs with UNION ALL
@jeffreyaven
Copy link
Member Author

closed in lieu of #594

@jeffreyaven jeffreyaven closed this Dec 2, 2025
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.

2 participants

Comments