Convert Druid planner to use statement handlers#12637
Closed
paul-rogers wants to merge 10 commits intoapache:masterfrom
Closed
Convert Druid planner to use statement handlers#12637paul-rogers wants to merge 10 commits intoapache:masterfrom
paul-rogers wants to merge 10 commits intoapache:masterfrom
Conversation
Converts the large collection of if-statements for statement types into a set of classes: one per supported statement type.
Contributor
Author
|
Closing for now; too much parallel change. Will redo later. |
5 tasks
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.
Druid has traditionally supported just one kind of SQL statement:
SELECT. The planner was thus designed to process "a query", and an ever-increasing amount of conditional code was added to support other statements such asINSERTandREPLACE. As we look toward adding DDL statements, the current approach will become unworkable. Other SQL products introduce an additional layer to handle statement types: the statement handler. This PR adds statement handlers to Druid.This PR builds on the single-pass planner PR to heavily refactor the Druid planner to split statement-specific code into a set of statement-specific handler classes. All handlers implement a simple interface:
The details of what is needed for each statement is a (complex) implementation detail of the handler classes.
At present, all the SQL statements which Druid supports include a
SELECT:EXPLAIN,INSERT,REPLACEand, of course,SELECTitself. To reflect this fact, a baseQueryHandlerclass handles the common aspects. As we add other statements (such as DDL), completely new handlers will handle those cases.For the most part, the code is identical between
masterand this PR, but the code is heavily refactored and shifted around.The key risk with this kind of change is that we break something. To catch any regression, this work was done in a private branch that also had the planner test framework. The planner artifacts (schema, logical plan, native query) were identical before and after the change. The various
Calcite?QueryTestcases provide a lighter validation in this PR itself, since the planner framework is not yet in master, nor is it included in this PR.Since the PR incorporates #12636, we should review and merge that PR first. I'll then rebase this one on the updated master which will remove the common code, leaving only the handler-related changes.
This PR has: