yashmayya commented on code in PR #13628:
URL: https://github.com/apache/pinot/pull/13628#discussion_r1680430202
##########
pinot-query-planner/src/main/java/org/apache/pinot/query/QueryEnvironment.java:
##########
@@ -190,14 +194,32 @@ public List<String> getTableNamesForQuery(String
sqlQuery) {
if (sqlNode.getKind().equals(SqlKind.EXPLAIN)) {
sqlNode = ((SqlExplain) sqlNode).getExplicandum();
}
- RelRoot relRoot = compileQuery(sqlNode, plannerContext);
+ RelRoot relRoot = compileAndOptimizeQuery(sqlNode, plannerContext);
Set<String> tableNames =
RelToPlanNodeConverter.getTableNamesFromRelRoot(relRoot.rel);
return new ArrayList<>(tableNames);
} catch (Throwable t) {
throw new RuntimeException("Error composing query plan for: " +
sqlQuery, t);
}
}
+ /**
+ * Returns whether the query can be successfully compiled in this query
environment
+ */
+ public boolean canCompileQuery(String query) {
+ try (PlannerContext plannerContext = getPlannerContext()) {
+ SqlNode sqlNode =
CalciteSqlParser.compileToSqlNodeAndOptions(query).getSqlNode();
+ if (sqlNode.getKind().equals(SqlKind.EXPLAIN)) {
+ sqlNode = ((SqlExplain) sqlNode).getExplicandum();
+ }
+ compileAndOptimizeQuery(sqlNode, plannerContext);
Review Comment:
In the initial version, I'd skipped the optimize step here for perf reasons
but turns out that there are some cases where bad queries are only caught in
the optimize step. For instance, [this
test](https://github.com/apache/pinot/blob/17332dea90183323f1eb3f1d15f01ddfdf94beee/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OfflineClusterIntegrationTest.java#L1058)
started failing because the bad query compiles fine but the
`PinotEvaluateLiteralRule` catches the issue during the optimize query phase.
--
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]