Skip to content

SQL summary: simplify jflex and support a couple of more cases#15986

Merged
laurit merged 3 commits intoopen-telemetry:mainfrom
trask:simplify-jflex
Jan 27, 2026
Merged

SQL summary: simplify jflex and support a couple of more cases#15986
laurit merged 3 commits intoopen-telemetry:mainfrom
trask:simplify-jflex

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Jan 24, 2026

No description provided.

trask added 2 commits January 23, 2026 17:45
Add rule to reset operation to none when encountering set operators,
allowing each SELECT in a UNION query to be processed independently.
This ensures proper table extraction for queries like:
SELECT ... FROM t1 UNION SELECT ... FROM t2 UNION SELECT ... FROM t3
@trask trask marked this pull request as ready for review January 24, 2026 02:15
@trask trask requested a review from a team as a code owner January 24, 2026 02:15
appendCurrentFragment();
if (isOverLimit()) return YYEOF;
}
"UNION" | "INTERSECT" | "EXCEPT" | "MINUS" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you could have something like

select
id,
(select max(foo) from (
  select foo from foos
  union all
  select foo from bars)
)) as foo
from main_table

will we loose main_table because of resetting the operation?

Copy link
Copy Markdown
Member Author

@trask trask Jan 26, 2026

Choose a reason for hiding this comment

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

this test case works, but agree it's a little mysterious

uncovered this issue #16007

will come back here after that is merged and see if I can find a breaking test case, and/or make the behavior clearer

setOperation(new Values());
appendOperationToSummary("VALUES");
}
if (shouldStartNewOperation()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can VALUES appear without a SELECT or INSERT so that the operation would be none?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, see this test case

// Standalone VALUES clause
Arguments.of("VALUES (1)", expect("VALUES (?)", null, null, "VALUES")),
Arguments.of(
"VALUES (1, 'a'), (2, 'b')", expect("VALUES (?, ?), (?, ?)", null, null, "VALUES")),

@laurit laurit merged commit 77eaa8c into open-telemetry:main Jan 27, 2026
85 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.

2 participants