Clone Calcite planner to access validator#12708
Conversation
78abe7f to
8ae28b4
Compare
|
Build is clean, except for a known flaky IT: 37272.52 (Compile=openjdk8, Run=openjdk8) perfect rollup parallel batch index integration test with Indexer, reported as Issue #12692. Ready for review. |
Done in preparation for the "single-pass" planner.
5c88bea to
5669dbf
Compare
|
Ready for review. Different flaky IT in the latest build: (Compile=openjdk8, Run=openjdk8) query retry integration test for missing segments, described in Issue #12733. |
| * In some future this could perhaps re-use some work done by {@link #validate(boolean)} | ||
| * instead of repeating it, but that day is not today. | ||
| */ | ||
| // RelConversionException is no longer thrown, but removing it causes |
There was a problem hiding this comment.
nit: is it really that many files?
There was a problem hiding this comment.
Yes! It expands ever-outward. Is good to clean up, but as a separate PR to keep this one small.
There was a problem hiding this comment.
got it, was curious because on the surface it only looks like SqlLifecycle and some tests. As long as we don't forget about it i think its fine.
There was a problem hiding this comment.
Right. From SqlLifecycle, the exception is exposed to the callers, which include the tests. Many tests then expose the exception in their test function signatures. So, to fully clean up, we have to clean up many test functions. That's the work to be done in another PR.
|
This PR also paves the way to support multiple SQL statements now that we have forked the PlannerImpl class. We could change the |
rohangarg
left a comment
There was a problem hiding this comment.
Thanks for the changes! 👍
left some comments
| System.setProperty("saffron.default.collation.name", StringUtils.format("%s$en_US", charset)); | ||
|
|
||
| // The following are the current names. See org.apache.calcite.config.CalciteSystemProperty | ||
| // https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java |
There was a problem hiding this comment.
thanks for checking up on this 👍 - can we also drop setting the old properties?
There was a problem hiding this comment.
Probably. I was being super-cautious to limit changes in this PR.
There is some mystery bug I never did solve: somewhere along the line Calcite stopped using our property values. If found this issue when trying to figure out why Calcite was ignoring our values.
| } | ||
|
|
||
| @Override | ||
| public RelNode transform( |
There was a problem hiding this comment.
is the dropping of RelConversionException from the Planner methods intended? I tried but could not figure out the reason for it
There was a problem hiding this comment.
As it turns out, Calcite declares an exception which is not thrown. Our IntelliJ inspections then refuse to allow this and require that we rectify Calcite's error. That causes the cascading issues mentioned elsewhere. This is a start to say that the exception isn't really thrown.
|
@abhishekagarwal87, good point:
The trick is that planning more than one statement at a time creates a race condition. In a normal DB, the following would fail: CREATE TABLE foo ...;
SELECT * FROM fooIf we plan both statements up front, the second will fail because table ALTER SESSION SET "priority" = 1;
SELECT ...One solution that some tools use is to first split the statements at the semi-colon delimiter, then plan and execute them one by one. That eliminates the race conditions. For the above, we could create a mini per-request "session" to track the options, seeded with query context values. |
|
Latest build failed with what I assume to be a flaky IT: (Compile=openjdk8, Run=openjdk8) leadership and high availability integration tests. The same IT passed in earlier builds, and nothing in the latest commit should affect the servers. The error says one of the servers failed to become ready. Perhaps a committer can kindly restart that one test to see if we get lucky this time. |
| * In some future this could perhaps re-use some work done by {@link #validate(boolean)} | ||
| * instead of repeating it, but that day is not today. | ||
| */ | ||
| // RelConversionException is no longer thrown, but removing it causes |
There was a problem hiding this comment.
got it, was curious because on the surface it only looks like SqlLifecycle and some tests. As long as we don't forget about it i think its fine.
Indeed. statements like Takes us one step closer to just submitting SQL as a string to Druid. Right now, that SQL needs to be wrapped up inside a JSON. |
This is a breakout from PR #12636: Single Pass through the Calcite planner. This PR adds just one item: a clone of the Calcite planner, lightly converted to Druid's coding style, with a method to provide access to the validator. The only tricky bit is the validator itself. While #12636 cloned the validator, this PR uses a sneaky approach: it defines
DruidSqlValidatoras a subclass of the unreachableCalciteSqlValidator. To do that, it lives in the same Calcite name space asCalciteSqlValidator. Some checkstyle hacking was needed to allow this odd state of affairs.There is zero change in functionality: everything works exactly as before. The goal here is simply to review the replacement of the Druid home-grown validator with the Calcite-provided one. This will then allow, in a later PR, to combine the validation and plan steps in the Druid planner.
Testing is handled by the large number of existing SQL tests, including integration tests.
This PR has: