Skip to content

[Backport] SQL planning: Consider subqueries in fewer scenarios. (#14123)#14140

Merged
vogievetsky merged 1 commit intoapache:26.0.0from
gianm:backport-14123-to-26.0.0
Apr 21, 2023
Merged

[Backport] SQL planning: Consider subqueries in fewer scenarios. (#14123)#14140
vogievetsky merged 1 commit intoapache:26.0.0from
gianm:backport-14123-to-26.0.0

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Apr 21, 2023

Backport of #14123 to 26.0.0.

* SQL planning: Consider subqueries in fewer scenarios.

Further adjusts logic in DruidRules that was previously adjusted in apache#13902.
The reason for the original change was that the comment "Subquery must be
a groupBy, so stage must be >= AGGREGATE" was no longer accurate. Subqueries
do not need to be groupBy anymore; they can really be any type of query.
If I recall correctly, the change was needed for certain window queries
to be able to plan on top of Scan queries.

However, this impacts performance negatively, because it causes many
additional outer-query scenarios to be considered, which is expensive.

So, this patch updates the matching logic to consider fewer scenarios. The
skipped scenarios are ones where we expect that, for one reason or another,
it isn't necessary to consider a subquery.

* Remove unnecessary escaping.

* Fix test.
@gianm gianm added the Backport label Apr 21, 2023
@gianm gianm added this to the 26.0 milestone Apr 21, 2023
@abhishekagarwal87 abhishekagarwal87 changed the title SQL planning: Consider subqueries in fewer scenarios. (#14123) [Backport] SQL planning: Consider subqueries in fewer scenarios. (#14123) Apr 21, 2023
@vogievetsky vogievetsky merged commit 37983b8 into apache:26.0.0 Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants