Skip to content

Conversation

@jeffreyaven
Copy link
Member

  • Implement CTE (Common Table Expression) support in execution layer

    • Extract CTEs from WITH clause during AST expansion
    • Convert CTE references to inline subqueries for processing
    • Store CTE registry in visitor for reference resolution
  • Add robot tests for window functions

    • ROW_NUMBER() OVER
    • SUM() OVER (with and without ORDER BY)
    • RANK() OVER
  • Add robot test for simple CTE usage

    • Test queries using WITH clause against accelerator types data

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

- Implement CTE (Common Table Expression) support in execution layer
  - Extract CTEs from WITH clause during AST expansion
  - Convert CTE references to inline subqueries for processing
  - Store CTE registry in visitor for reference resolution

- Add robot tests for window functions
  - ROW_NUMBER() OVER
  - SUM() OVER (with and without ORDER BY)
  - RANK() OVER

- Add robot test for simple CTE usage
  - Test queries using WITH clause against accelerator types data
… complexity

Move CTE reference handling into separate processCTEReference method
to satisfy nestif linter complexity requirements.
- Remove unused error return from processCTEReference (unparam fix)
- Extract visitAliasedTableExpr helper method to reduce nesting (nestif fix)
…olution

The CTE implementation was storing an indirect but not modifying the
original AST node. This caused GetHIDs to still see a TableName type
instead of a Subquery type, resulting in "could not locate table" errors.

Fix: Modify the original node.Expr to be the CTE's Subquery instead of
creating a synthetic expression. This ensures downstream code correctly
recognizes the CTE reference as a subquery.

Also re-enables the CTE robot test.
@jeffreyaven jeffreyaven merged commit a6bcfc3 into main Dec 1, 2025
19 checks passed
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.

3 participants