You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/29 07:14:35 UTC

[GitHub] [flink] slinkydeveloper commented on a change in pull request #18179: [FLINK-8518][Table SQL / API] Add support for extract Epoch

slinkydeveloper commented on a change in pull request #18179:
URL: https://github.com/apache/flink/pull/18179#discussion_r837128131



##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/utils/DateTimeUtils.java
##########
@@ -1137,25 +1137,29 @@ private static long convertExtract(
                     return divide(utcTs, TimeUnit.DAY.multiplier);
                 } else {
                     // TODO support it
-                    throw new TableException(type + " is unsupported now.");
+                    throw new TableException(startUnit + " for " + type + " is unsupported now.");
                 }
             case EPOCH:
-                // TODO support it
-                throw new TableException("EPOCH is unsupported now.");
+                if (type instanceof TimestampType || type instanceof DateType) {

Review comment:
       Can you use `type.isAnyOf` here?

##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/utils/DateTimeUtils.java
##########
@@ -1137,25 +1137,29 @@ private static long convertExtract(
                     return divide(utcTs, TimeUnit.DAY.multiplier);
                 } else {
                     // TODO support it
-                    throw new TableException(type + " is unsupported now.");
+                    throw new TableException(startUnit + " for " + type + " is unsupported now.");
                 }
             case EPOCH:
-                // TODO support it
-                throw new TableException("EPOCH is unsupported now.");
+                if (type instanceof TimestampType || type instanceof DateType) {
+                    return utcTs / 1000;
+                } else {
+                    // TODO support it
+                    throw new TableException(startUnit + " for " + type + " is unsupported now.");
+                }
             case MICROSECOND:
                 if (type instanceof TimestampType) {

Review comment:
       `type.is`




-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org