zachjsh commented on code in PR #15836:
URL: https://github.com/apache/druid/pull/15836#discussion_r1481931968
##########
sql/src/main/java/org/apache/druid/sql/calcite/parser/DruidSqlParserUtils.java:
##########
@@ -96,28 +104,61 @@
}
/**
- * This method is used to extract the granularity from a SqlNode
representing following function calls:
- * 1. FLOOR(__time TO TimeUnit)
- * 2. TIME_FLOOR(__time, 'PT1H')
+ * This method is used to extract the granularity from a SqlNode which
represents
+ * the argument to the {@code PARTITIONED BY} clause. The node can be any of
the following:
+ * <ul>
+ * <li>A literal with a string that matches the SQL keywords
+ * {@code HOUR, DAY, MONTH, YEAR, ALL [TIME]}</li>
+ * <li>A literal string with a period in ISO 8601 format.</li>
+ * <li>Function call: {@code FLOOR(__time TO TimeUnit)}</li>
+ * <li>Function call: TIME_FLOOR(__time, 'PT1H')}</li>
+ * </ul>
* <p>
- * Validation on the sqlNode is contingent to following conditions:
- * 1. sqlNode is an instance of SqlCall
- * 2. Operator is either one of TIME_FLOOR or FLOOR
- * 3. Number of operands in the call are 2
- * 4. First operand is a SimpleIdentifier representing __time
- * 5. If operator is TIME_FLOOR, the second argument is a literal, and can
be converted to the Granularity class
- * 6. If operator is FLOOR, the second argument is a TimeUnit, and can be
mapped using {@link TimeUnits}
+ * Validation of the function sqlNode is contingent to following conditions:
+ * <ol>
+ * <li>sqlNode is an instance of SqlCall</li>
+ * <li>Operator is either one of TIME_FLOOR or FLOOR</li>
+ * <li>Number of operands in the call are 2</li>
+ * <li>First operand is a SimpleIdentifier representing __time</li>
+ * <li>If operator is TIME_FLOOR, the second argument is a literal, and can
be converted to the Granularity class</li>
+ * <li>If operator is FLOOR, the second argument is a TimeUnit, and can be
mapped using {@link TimeUnits}</li>
+ * </ol>
* <p>
- * Since it is to be used primarily while parsing the SqlNode, it is wrapped
in {@code convertSqlNodeToGranularityThrowingParseExceptions}
+ * This method is called during validation, which will catch any errors. It
is then called again
+ * during conversion, at which time we assume the node is valid.
*
* @param sqlNode SqlNode representing a call to a function
*
* @return Granularity as intended by the function call
*
- * @throws ParseException SqlNode cannot be converted a granularity
+ * @throws InvalidSqlInput if SqlNode cannot be converted to a granularity
Review Comment:
fixed
##########
docs/multi-stage-query/reference.md:
##########
@@ -199,6 +199,33 @@ The following ISO 8601 periods are supported for
`TIME_FLOOR` and the string con
- P3M
- P1Y
+The string constant can also include any of the keywords mentioned above:
+
+- `HOUR` - Same as `'PT1H'`
+- `DAY` - Same as `'P1D'`
+- `MONTH` - Same as `'P1M'`
+- `YEAR` - Same as `'P1Y'`
+- `ALL TIME`
+- `ALL` - Alias for `ALL TIME`
+
+The `WEEK` granularity is deprecated and not supported in MSQ.
+
+Examples:
+
+```SQL
+-- Keyword
+PARTITIONED BY HOUR
+
+-- String constant
+PARTITIONED BY 'HOUR'
+
+-- Or
+PARTITIOND BY 'PT1H'
Review Comment:
fixed
--
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]