sqlapache-flinkflink-sql

Build a JSON_Object value in Flink SQL


I have a Flink Table for which I want to write a select query that will return a JSON Object based on some fields.

Here is the query I want to do (based on calcite syntax : https://calcite.apache.org/docs/reference.html#constructor-functions):

SELECT 
    myIdField,
    aFloatField,
    JSON_OBJECT('aFieldName':aFloatField)
FROM myTable

But when I try to use this query with Flink, I get the following error :

org.apache.flink.table.api.ValidationException: SQL validation failed. No match found for function signature JSON_OBJECT(<null>, , )

What is the good way to do so ? I can't find anything about this in Flink documentation.


Solution

  • JSON_OBJECT is supported in Flink 1.15:

    https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/functions/systemfunctions/#json-functions