gortiz commented on code in PR #15277:
URL: https://github.com/apache/pinot/pull/15277#discussion_r2005729667


##########
pinot-query-planner/src/main/java/org/apache/pinot/query/QueryEnvironment.java:
##########
@@ -278,53 +204,69 @@ private QueryEnvironment.QueryPlannerResult 
getQueryPlannerResult(PlannerContext
     return new QueryPlannerResult(dispatchableSubPlan, explainStr, tableNames, 
extraFields);
   }
 
+  /// @deprecated Use [#compile] and then 
[explain][CompiledQuery#explain(long) ] the returned query instead
   @VisibleForTesting
+  @Deprecated
   public String explainQuery(String sqlQuery, long requestId) {
     SqlNodeAndOptions sqlNodeAndOptions = 
CalciteSqlParser.compileToSqlNodeAndOptions(sqlQuery);
-    QueryPlannerResult queryPlannerResult = explainQuery(sqlQuery, 
sqlNodeAndOptions, requestId, null);
-    return queryPlannerResult.getExplainPlan();
+    try (CompiledQuery compiledQuery = compile(sqlQuery, sqlNodeAndOptions)) {
+      QueryPlannerResult queryPlannerResult = compiledQuery.explain(requestId, 
null);
+      return queryPlannerResult.getExplainPlan();
+    }
   }
 
-  public List<String> getTableNamesForQuery(String sqlQuery) {
-    SqlNodeAndOptions sqlNodeAndOptions = 
CalciteSqlParser.compileToSqlNodeAndOptions(sqlQuery);
-    try (PlannerContext plannerContext = getPlannerContext(sqlNodeAndOptions)) 
{
+  public CompiledQuery compile(String sqlQuery) {
+    return compile(sqlQuery, 
CalciteSqlParser.compileToSqlNodeAndOptions(sqlQuery));
+  }
+
+  /// Given a query, parses, validates and optimizes the query into a 
[CompiledQuery].
+  ///
+  /// The returned query can then be planned, explained or used to get the 
tables involved in the query.
+  ///
+  /// @throws QueryException if the query cannot be compiled. Usual error 
types are [QueryErrorCode#SQL_PARSING] and
+  /// [QueryErrorCode#QUERY_VALIDATION]. [QueryErrorCode#QUERY_EXECUTION] is 
also possible if there is an error when
+  /// a function call is reduced into a constant.

Review Comment:
   I think so, yes. At least, that is the theory.



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to