Fix the error case when there are multi top level unions#12017
Merged
abhishekagarwal87 merged 7 commits intoapache:masterfrom Dec 6, 2021
Merged
Fix the error case when there are multi top level unions#12017abhishekagarwal87 merged 7 commits intoapache:masterfrom
abhishekagarwal87 merged 7 commits intoapache:masterfrom
Conversation
| .collect(Collectors.toList()); | ||
|
|
||
| } | ||
| catch (UnsupportedOperationException unsupportedOperationException) { |
Contributor
There was a problem hiding this comment.
are you throwing unsupportedOperationException somewhere in the code path? I am wondering why is it being caught separately.
Contributor
Author
There was a problem hiding this comment.
DruidUnionRel throws it for unsupported operations: DruidUnionRel Those operations which can be done on queries which translate directly to native queries). Here toDruidQuery can throw the exception.
Contributor
|
Merged since CI failure is unrelated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a follow up to the PR #11908. This fixes the bug in top level union all queries when there are more than 2 SQL subqueries are present. For example, if the following query was passed:
it would fail to be explained in the newer format, and would revert to the original plan.
Reason for the bug: In the original PR, I assumed that
DruidUnionRelcan only be the top level DruidRel node after parsing, according to the comment here, and all the three queries would be children to that top level parent node.When there are more than 2 queries connected by a top level UNION ALL, then the DruidRel structure looks like this:
This PR introduces a recursive method which flattens this structure, and produces the native queries as expected.
Key changed/added classes in this PR
DruidPlannerThis PR has: