Hi All, Seeing an error with Table API when using ...
# troubleshooting
d
Hi All, Seeing an error with Table API when using select from table. As per this (https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/table/functions/systemfunctions/), the currentDate() should be equivalent to CURRENT_DATE, but I see it is transformed to TIMESTAMP_LTZ(3). Running into following error because of that :
Copy code
org.apache.flink.table.api.ValidationException: Column types of query result and sink for 'default_catalog.default_database.table_name' do not match.
Cause: Incompatible types for sink column 'summary_date' at position 2.

Query schema: [*********, summary_date: TIMESTAMP_LTZ(3) NOT NULL, **********]
Sink schema:  [*********, summary_date: DATE, *******************************]
Can someone please help look at this ? Thanks
m
CURRENT_DATE
is not a data type, but a function. That's indeed represented as TIMESTAMP_LTZ(3). If you want to sink it to a column which has a DATE data type, you would need to cast it to a DATE
d
Thanks @Martijn Visser for your response. We have different expressions currentDate() and currentTimestamp() . As per the doc, the currentDate() function should match the SQL Function CURRENT_DATE which can be used to put a value to a DATE type Column. Where as currentTimestamp() function should match the SQL Function CURRENT_TIMESTAMP which can be used to put a value to a TIMESTAMP type columns. Also to add, if instead of using
table.select(_currentDate_().as("summary_date")
, if I write SqlQuery
select CURRENT_DATE as summary_date
it work fine and gets the value as a DATE and not timestamp Please let me know if the above understanding is incorrect. Thanks.
Can you file a Jira ticket? I'm kind of surprised that this wouldn't be picked up by a test
j
@Dheeraj Panangat what version of flink are you running?
d
Sure @Martijn Visser @Jason Politis, we are using 1.16.1
Ticket Created : FLINK-31985