Фильтрация Flink Table по полю типа Date - PullRequest
0 голосов
/ 29 января 2019

Я создал таблицу с одним полем типа Дата, а именно 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.Как я могу дать дату в правильном формате!?

1 Ответ

0 голосов
/ 24 февраля 2019

Я должен преобразовать Строка в Дата , используя метод toDate.

filter("f_date <= '1998-10-02'.toDate")
...