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

   This PR was split out of the ["big" catalog 
PR](https://github.com/apache/druid/pull/13686/commits).
   
   Refactors the Druid planner to move `INSERT` and `REPLACE` validation out of 
the statement handers and into the Calcite validator. This is the right place 
for validation in general, and is required for the catalog integration to be 
added in a separate PR.
    PRs added the catalog (table metadata) foundations, and an improved set of 
table functions. This PR brings it all together:
   
   * Validates the MSQ INSERT and REPLACE statements against the catalog
   * Extends the PARTITION BY clause to accept string literals for the time 
partitioning
   
   To allow all the above to work:
   
   * Validation for MSQ statements moves out of the handers into a 
Druid-specific version of the SQL validator.
   * Druid-specific Calcite operator to represent a Druid ingest.
   Most changes are purely mechanical. One that is not is the way that the 
`PARTITIONED BY` grain is represented in the AST. Prior to this commit, 
`PARTITIONED BY` was represented as a Druid granularity object. However, the 
Calcite validator requires that all properties of an AST node be a subclass of 
`SqlNode`, which `Granularity` is not. To solve this, the granularity is 
represented as a string `SqlLiteral` in the AST, and validated into a Druid 
granularity in the validator. This is probably a better choice, now that we can 
do it. A side effect of this change is that the parser can now allow string 
literals for `PARTITIONED BY`. Example: `PARTITIONED BY 'P1D'`. This seems safe 
because, in Druid, partitioning is always by time and gives the segment grain. 
We are unlikely to change the segment grain idea any time soon.
   
   This PR also forbids the use of the `WEEK` (or `P1W`) granularity, since 
earlier feedback indicated we no longer wish to support that gain.
   
   #### Release note
   
   This PR introduces another option for how to specify time granularity: by 
using ISO-8601 periods and Druid period names as a string argument to 
`PARTITIONED BY`. See `reference.md` for details.
   
   #### Hints to reviewers
   
   The real core of this PR is 
`sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidSqlValidator.java`:
 the place where we moved the former ad-hoc `INSERT` and `REPLACE` validation 
to instead run within the SQL validator.
   
   No runtime code was changed: all the non-trivial changes are in the SQL 
planner.
   
   The code here is identical to that in the "full" PR: all prior review 
comments are reflected. The only difference is that the validator in this PR 
omits the catalog integration from the full PR.
   
   <hr>
   
   This PR has:
   
   - [X] been self-reviewed.
   - [X] added documentation for new or modified features or behaviors.
   - [X] a release note entry in the PR description.
   - [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.
   - [X] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [ ] 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