Extend the PARTITIONED BY clause to accept string literals for the time partitioning#15836
Conversation
| | | ||
| e = Expression(ExprContext.ACCEPT_SUB_QUERY) | ||
| { | ||
| granularity = DruidSqlParserUtils.convertSqlNodeToGranularityThrowingParseExceptions(e); |
There was a problem hiding this comment.
I think some validation should happen here; I don't see a nice way to do it but I've found this:
result = new SqlLiteral(DruidSqlParserUtils.convertSqlNodeToGranularityThrowingParseExceptions(e), SYMBOL, getPos());
which might work (but the typeName must be supplied - other candidate could be: UNKNOWN )
There was a problem hiding this comment.
Added validation here in another way, let me know if ok.
There was a problem hiding this comment.
ok - but why not do the conversion here - I think you might also able to do similar thing on all the other branches
result = new SqlLiteral(DruidSqlParserUtils.convertSqlNodeToGranularityThrowingParseExceptions(e), SYMBOL, getPos());
you could shortcut the transient String + Symbol stuff
There was a problem hiding this comment.
Added a new SqlNode type, let me know if good now.
abhishekrb19
left a comment
There was a problem hiding this comment.
Had a few questions and suggestions. Also, to future proof this new functionality, I would recommend adding tests in different parts of the code in case things get lost with refactoring or something breaks between Calcite upgrades. For example, https://github.com/apache/druid/blob/master/sql/src/test/java/org/apache/druid/sql/calcite/CalciteInsertDmlTest.java#L608 could be extended to test the newly added literal support.
abhishekrb19
left a comment
There was a problem hiding this comment.
Thanks for the changes @zachjsh!
| private String unparseString; | ||
| private Granularity granularity; |
| @Override | ||
| public void unparse(SqlWriter writer, int leftPrec, int rightPrec) | ||
| { | ||
| if (unparseString != null) { |
There was a problem hiding this comment.
note: not sure if you need to be defensive here; its @NonNull in the constructor
| } | ||
| } | ||
|
|
||
| private static Granularity convertSqlIdentiferToGranularity(SqlIdentifier identifier) |
There was a problem hiding this comment.
these 2 methods are almost identical; the difference is how they get to the String ; can you leave just one with a String arg - and do the X2String conversion before calling that method?
…urce input expressions (#15962) * * address remaining comments from #15836 * * address remaining comments from #15908 * * add test that exposes relational algebra issue * * simplify test exposing issue * * fix * * add tests for sealed / non-sealed * * update test descriptions * * fix test failure when -Ddruid.generic.useDefaultValueForNull=true * * check type assignment based on natice Druid types * * add tests that cover missing jacoco coverage * * add replace tests * * add more tests and comments about column ordering * * simplify tests * * review comments * * remove commented line * * STRING family types should be validated as non-null
Description
This PR contains a portion of the changes from the inactive draft PR for integrating the catalog with the Calcite planner #13686 from @paul-rogers, extending the PARTITION BY clause to accept string literals for the time partitioning
This PR has: