abhishekagarwal87 commented on a change in pull request #11908:
URL: https://github.com/apache/druid/pull/11908#discussion_r752253808
##########
File path:
sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
##########
@@ -384,6 +399,46 @@ private PlannerResult planExplanation(
return new PlannerResult(resultsSupplier,
getExplainStructType(rel.getCluster().getTypeFactory()));
}
+ /**
+ * This method doesn't utilize the Calcite's internal {@link
RelOptUtil#dumpPlan} since that tends to be verbose
+ * and not indicative of the native Druid Queries which will get executed
+ * This method assumes that the Planner has converted the RelNodes to
DruidRels, and thereby we can implictly cast it
+ *
+ * @param rel Instance of the root {@link DruidRel} which is formed by
running the planner transformations on it
+ * @return A string representing an array of native queries that correspond
to the given SQL query, in JSON format
+ * @throws JsonProcessingException
+ */
+ private String explainSqlPlanAsNativeQueries(DruidRel<?> rel) throws
JsonProcessingException
+ {
+ // Only if rel is an instance of DruidUnionRel, do we run multiple native
queries corresponding to single SQL query
+ // Also, DruidUnionRel can only be a top level node, so we don't need to
check for this condition in the subsequent
+ // child nodes
+ List<DruidQuery> druidQueryList;
+ if (rel instanceof DruidUnionRel) {
+ druidQueryList = rel.getInputs().stream().map(childRel -> (DruidRel<?>)
childRel).map(childRel -> {
+ if (childRel instanceof DruidUnionRel) {
+ log.error("DruidUnionRel can only be the outermost RelNode. This
error shouldn't be encountered");
+ // TODO: Throw an error here
Review comment:
should you throw an error here?
--
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]