normanj-bitquill commented on code in PR #3794:
URL: https://github.com/apache/calcite/pull/3794#discussion_r1626468035
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java:
##########
@@ -3104,8 +3105,18 @@ private static class ExtractImplementor extends
AbstractRexCallImplementor {
@Override Expression implementSafe(final RexToLixTranslator translator,
final RexCall call, final List<Expression> argValueList) {
- final TimeUnitRange timeUnitRange =
- (TimeUnitRange) translator.getLiteralValue(argValueList.get(0));
+ // May need to convert the first argument from a String to a
TimeUnitRange
+ final Object timeUnitRangeObj =
translator.getLiteralValue(argValueList.get(0));
+ final TimeUnitRange timeUnitRange;
+ if (timeUnitRangeObj instanceof String) {
Review Comment:
During validation, it will test the value and return an error if not valid.
https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L3484
I have added a test for this error. It results in an error message like this:
```
java.sql.SQLException: Error while executing SQL "select date_part('foo',
timestamp '2022-06-03 12:15:48.678')": From line 1, column 18 to line 1, column
22: 'foo' is not a valid time frame
```
--
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]