olivrlee commented on code in PR #3009: URL: https://github.com/apache/calcite/pull/3009#discussion_r1065125968
########## core/src/main/codegen/templates/Parser.jj: ########## @@ -5050,6 +5050,86 @@ SqlIntervalQualifier TimeUnitOrName() : { } } + SqlIntervalQualifier TimeUnitOrNameForDateTrunc() : { + final TimeUnit timeUnit; + final SqlIntervalQualifier weekdayIntervalQualifier; + final SqlIdentifier unitName; +} +{ + LOOKAHEAD(1) + timeUnit = TimeUnitForDateTrunc() { + return new SqlIntervalQualifier(timeUnit, null, getPos()); + } +| + weekdayIntervalQualifier = WeekWeekdaySqlIntervalQualifier() { + return weekdayIntervalQualifier; + } +| + unitName = DateTruncIdentifiers() { + return new SqlIntervalQualifier(unitName.getSimple(), + unitName.getParserPosition()); + } +} + +/** Parses time unit for the DATE_TRUNC function. +* This is a subset of time units appropriate for DATE data type. +*/ +TimeUnit TimeUnitForDateTrunc() : {} +{ + <DAY> { return TimeUnit.DAY; } +| <MONTH> { return TimeUnit.MONTH; } +| <QUARTER> { return TimeUnit.QUARTER; } +| <YEAR> { return TimeUnit.YEAR; } +} + +SqlIntervalQualifier WeekWeekdaySqlIntervalQualifier() : { + final String weekdayName; +} +{ + weekdayName = WeekWeekday() { + return new SqlIntervalQualifier(weekdayName, getPos()); + } +} +String WeekWeekday() : Review Comment: Yep I have this followup https://issues.apache.org/jira/browse/CALCITE-5450 to add to all the other functions, but I'd like to get this reviewed before I go and do that -- 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...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org