【发布时间】:2019-02-24 15:44:31
【问题描述】:
我创建了一个表,其中有一个日期类型的字段,即 f_date。我想要的查询的一部分基于 f_date 字段过滤表行。所以我做了以下事情:
mytable.filter("f_date <= '1998-10-02'")
和
mytable.filter("f_date <= '1998/10/02'")
然后我在所有两种情况下都得到了以下相同的错误:
Expression 'f_date <= 1998/10/02 failed on input check: Comparison is only supported for numeric types and comparable types of the same type, got Date and String
我什至删除了单引号并尝试了:
mytable.filter("f_date <= 1998/10/02")
我得到了错误:
Expression 'f_date <= ((1998 / 10) / 2) failed on input check: Comparison is only supported for numeric types and comparable types of same type, got Date and Integer
最后我创建了一个 Date 对象并尝试:
mytable.filter("f_date <=" + Java.sql.Date.valueOf("1998-10-22"))
我得到了错误:
Expression 'f_date <= ((1998 - 10) - 2) failed on input check: Comparison is only supported for numeric types and comparable types of the same type, got Date and Integer
在上述情况下,Flink 将日期识别为 String 或 Integer。我怎样才能以正确的格式给出日期!?
【问题讨论】: