You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "abhishekrb19 (via GitHub)" <gi...@apache.org> on 2023/06/25 03:08:47 UTC
[GitHub] [druid] abhishekrb19 commented on a diff in pull request #14441: Improvements to `EXPLAIN PLAN` attributes
abhishekrb19 commented on code in PR #14441:
URL: https://github.com/apache/druid/pull/14441#discussion_r1241009757
##########
sql/src/main/java/org/apache/druid/sql/calcite/parser/DruidSqlParserUtils.java:
##########
@@ -302,6 +309,82 @@ public static SqlOrderBy convertClusterByToOrderBy(SqlNode query, SqlNodeList cl
);
}
+ /**
+ * Return resolved clustered by columns specified to output columns.
+ * For example,
+ * EXPLAIN PLAN FOR
+ * INSERT INTO w000
+ * SELECT
+ * TIME_PARSE("timestamp") AS __time,
+ * page AS page_alias,
+ * FLOOR("cost"),
+ * country,
+ * citName
+ * FROM ...
+ * PARTITIONED BY DAY
+ * CLUSTERED BY 1, 2, 3, cityName
+ *
+ * The above SQL will return the following clusteredBy columns: ["__time", "page_alias", "FLOOR(\"cost\")", cityName"]
+ * Any ordinal and expression specified in the CLUSTERED BY clause will resolve to the final output column name.
+ * @param clusteredByNodes List of {@link SqlNode}s representing columns to be clustered by.
+ * @param sourceNode The select or order by source node.
+ */
+ @Nullable
+ public static List<String> resolveClusteredByColumnsToOutputColumns(SqlNodeList clusteredByNodes, SqlNode sourceNode)
+ {
+ // CLUSTERED BY is an optional clause
+ if (clusteredByNodes == null) {
+ return null;
+ }
+
+ Preconditions.checkArgument(sourceNode instanceof SqlOrderBy || sourceNode instanceof SqlSelect,
Review Comment:
This is basically where the output names can be extracted from: [SqlSelect](https://calcite.apache.org/javadocAggregate/org/apache/calcite/sql/SqlSelect.html) projections or `SqlOrderBy` since we convert them [here](https://github.com/apache/druid/blob/master/sql/src/main/java/org/apache/druid/sql/calcite/parser/DruidSqlParserUtils.java#L278)
--
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-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org