Skip to content

Comments

Introduce Visit::visit_select#2235

Merged
iffyio merged 6 commits intoapache:mainfrom
xitep:visit-select
Feb 24, 2026
Merged

Introduce Visit::visit_select#2235
iffyio merged 6 commits intoapache:mainfrom
xitep:visit-select

Conversation

@xitep
Copy link
Contributor

@xitep xitep commented Feb 23, 2026

  • SetExpr is a directly recursive data-structure through SetExpr::SetOperation
  • Its visit impl dispatches directly to Select (without necessary going through Query first)
  • Right now a Visitor impl has no chance to observe when a SELECT starts and ends during the traversal

The motivation is that SELECTs often introduce aliases which are valid only for that particular SELECT.

select * 
  from (select 1 val from dual) x
 where x.val = 1

 union all

select *
  from (select 2 val from dual) y
 where y.val = 2

-- referring to `x` at this point is an error (at least on oracle)
-- referring to `x` or `y` as part of an `order by` is an error (at least on oracle)

This change allows effectively to determine the scope of a (nested) SELECT using Visitor/Mut.

Alternatively we could drop the SetExpr::Select variant and replace it entirely with the existing SetExpr::Query; after all, a Select is a Query's body. (My personal preference, however, would be to keep the current structure as it makes the AST easier to follow / navigate / more expressive.)

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @xitep!

@iffyio iffyio added this pull request to the merge queue Feb 24, 2026
Merged via the queue into apache:main with commit d9b53a0 Feb 24, 2026
10 checks passed
@xitep xitep deleted the visit-select branch February 24, 2026 14:26
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