normanj-bitquill commented on code in PR #3794:
URL: https://github.com/apache/calcite/pull/3794#discussion_r1626468768
##########
core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java:
##########
@@ -445,6 +446,53 @@ public int getIntervalSign(String value) {
return sign;
}
+ public static TimeUnit stringToDatePartTimeUnit(String stringValue) {
+ final String timeUnitString = stringValue.toUpperCase(Locale.ROOT);
+
+ switch (timeUnitString) {
+ case "MICROSECOND":
+ return TimeUnit.MICROSECOND;
+ case "MILLISECOND":
+ return TimeUnit.MILLISECOND;
+ case "SECOND":
+ return TimeUnit.SECOND;
+ case "MINUTE":
+ return TimeUnit.MINUTE;
+ case "HOUR":
+ return TimeUnit.HOUR;
+ case "DAY":
+ return TimeUnit.DAY;
+ case "DAYOFWEEK":
+ case "DOW":
+ return TimeUnit.DOW;
+ case "DAYOFYEAR":
+ case "DOY":
+ return TimeUnit.DOY;
+ case "ISODOW":
+ return TimeUnit.ISODOW;
+ case "ISODOY":
+ return TimeUnit.ISOYEAR;
+ case "WEEK":
+ return TimeUnit.WEEK;
+ case "MONTH":
+ return TimeUnit.MONTH;
+ case "QUARTER":
+ return TimeUnit.QUARTER;
+ case "YEAR":
+ return TimeUnit.YEAR;
+ case "EPOCH":
+ return TimeUnit.EPOCH;
+ case "DECADE":
+ return TimeUnit.DECADE;
+ case "CENTURY":
+ return TimeUnit.CENTURY;
+ case "MILLENNIUM":
+ return TimeUnit.MILLENNIUM;
+ default:
+ throw new IllegalArgumentException();
Review Comment:
I have added a message to the exception.
--
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]