paul-rogers opened a new pull request, #12905:
URL: https://github.com/apache/druid/pull/12905

   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 as 
`INSERT` and `REPLACE`. 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](https://github.com/apache/druid/pull/12636) 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:
   
   ```java
   interface SqlStatementHandler
   {
     SqlNode sqlNode();
     void validate() throws ValidationException;
     Set<ResourceAction> resourceActions();
     void prepare();
     PrepareResult prepareResult();
     PlannerResult plan() throws ValidationException;
   }
   ```
   
   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`, `REPLACE` and, of course, `SELECT` itself. To reflect this 
fact, a base `QueryHandler` class 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 `master` and this PR, but 
the code is heavily refactored and shifted around.
   
   This PR is a step toward modifying the SQL validator to handle the newer 
`INSERT` and `REPLACE` nodes. The validation logic for these two statements 
that migrated to handers in this PR will migrate again into a Druid version of 
the Calcite validator.
   
   <hr>
   
   This PR has:
   - [X] been self-reviewed.
   - [X] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [X] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [ ] been tested in a test Druid cluster.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to