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


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/FlinkCalciteSqlValidator.java:
##########
@@ -222,14 +223,23 @@ 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);
+            RexLiteral rexLiteral = (RexLiteral) reducedNode;
+            final SqlTypeName sqlTypeName = rexLiteral.getTypeName();
+            if (!(sqlTypeName == SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE
+                    || sqlTypeName == SqlTypeName.TIMESTAMP)) {

Review Comment:
   ```suggestion
               if (!SqlTypeUtil.isTimestamp(sqlTypeName) {
   ```
   I think `org.apache.calcite.sql.type.SqlTypeUtil#isTimestamp` could be 
reused here
   as defined at 
   
https://github.com/apache/calcite/blob/413eded693a9087402cc1a6eefeca7a29445d337/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java#L390-L393
   
   and 
   
https://github.com/apache/calcite/blob/413eded693a9087402cc1a6eefeca7a29445d337/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFamily.java#L182-L183
   
   



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