apache-calcite

TO_TIMESTAMP function can not be resolved in calcite


I am using calcite library to query my data using API , I found function called TO_TIMESTAMP https://calcite.apache.org/docs/reference.html but when I called it give exception that there are no function with this signature

what I try to do :

SELECT TO_TIMESTAMP(cast(ORGINALTIMESTAMP as varchar),cast('yyyy-MM-dd HH:mm:ss' as varchar)) as  TEST from my_table

the exception that I got :

No match found for function signature TO_TIMESTAMP(<CHARACTER>, <CHARACTER>)

any idea what is the wrong that I am doing ?


Solution

  • To solve the problem, include fun=postgresql in the JDBC connect string that you use to connect to Calcite, which starts with jdbc:calcite:.

    In Calcite, TO_TIMESTAMP is a dialect-specific operator. This means that it is not included in the default dialect, and that is why it appears in Calcite's table of dialect-specific operators.

    The 'c' (compatibility) column for TO_TIMESTAMP contains the values 'o p', meaning that TO_TIMESTAMP is enabled in Oracle and PostgreSQL function tables. That is why fun=postgresql solves the problem; fun=oracle would also work.