[
https://issues.apache.org/jira/browse/FLINK-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14987390#comment-14987390
]
ASF GitHub Bot commented on FLINK-2961:
---------------------------------------
Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/1322#discussion_r43755112
--- Diff:
flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
---
@@ -202,6 +210,23 @@ abstract class ExpressionCodeGenerator[R](
""".stripMargin
}
+ case expressions.Literal(dateValue: Date, DATE_TYPE_INFO) =>
+ val dateName = s"""date_${dateValue.getTime}"""
+ val dateStmt = s"""static java.util.Date $dateName
+ |= new java.util.Date(${dateValue.getTime});""".stripMargin
+ reusableStatements.add(dateStmt)
+
+ if (nullCheck) {
+ s"""
+ |val $nullTerm = false
--- End diff --
Aren't you generating Java code here? This should not work with `val`. I
assume that you don't have a test case where you generate this code. Otherwise
it should have failed. I guess it would be good to add a test case for it.
> Add support for basic type Date in Table API
> --------------------------------------------
>
> Key: FLINK-2961
> URL: https://issues.apache.org/jira/browse/FLINK-2961
> Project: Flink
> Issue Type: Improvement
> Components: Table API
> Reporter: Timo Walther
> Assignee: Timo Walther
> Priority: Minor
>
> Currently, the basic type {{Date}} is not implemented in the Table API. In
> order to have a mapping of the most important ANSI SQL types for FLINK-2099.
> It makes sense to add support for {{Date}} to represent date, time and
> timestamps of milliseconds precision.
> Only the types `LONG` and `STRING` can be casted to `DATE` and vice versa. A
> `LONG` casted to `DATE` must be a milliseconds timestamp. A `STRING` casted
> to `DATE` must have the format "`yyyy-MM-dd HH:mm:ss.SSS`", "`yyyy-MM-dd`",
> "`HH:mm:ss`", or a milliseconds timestamp. All timestamps refer to the UTC
> timezone beginning from January 1, 1970, 00:00:00 in milliseconds.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)