dawidwys commented on code in PR #24534:
URL: https://github.com/apache/flink/pull/24534#discussion_r1530725846


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/FlinkCalciteSqlValidator.java:
##########
@@ -222,15 +223,25 @@ protected void registerNamespace(
                             Collections.singletonList(simplifiedRexNode),
                             reducedNodes);
             // check whether period is the unsupported expression
-            if (!(reducedNodes.get(0) instanceof RexLiteral)) {
-                throw new UnsupportedOperationException(
+            final RexNode reducedNode = reducedNodes.get(0);
+            if (!(reducedNode instanceof RexLiteral)) {
+                throw new ValidationException(
                         String.format(
                                 "Unsupported time travel expression: %s for 
the expression can not be reduced to a constant by Flink.",
                                 periodNode));
             }
 
-            RexLiteral rexLiteral = (RexLiteral) (reducedNodes).get(0);
-            TimestampString timestampString = 
rexLiteral.getValueAs(TimestampString.class);
+            final SqlTypeName sqlTypeName = ((RexLiteral) 
reducedNode).getTypeName();
+            if (!(sqlTypeName == SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE
+                    || sqlTypeName == SqlTypeName.TIMESTAMP)) {
+                throw newValidationError(
+                        periodNode,
+                        
Static.RESOURCE.illegalExpressionForTemporal(sqlTypeName.getName()));
+            }
+
+            RexLiteral rexLiteral = (RexLiteral) reducedNode;
+            TimestampString timestampString =
+                    ((RexLiteral) 
reducedNode).getValueAs(TimestampString.class);

Review Comment:
   ah, I wanted to delete the line with `rexLiteral` 🤦 



-- 
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]

Reply via email to