Hi all

Trying to use the from_json call in Flink SQL

As per below...


This is on Apache Flink 1.20.2

Searching implied I require the below jar file, this has been added...

https://repo1.maven.org/maven2/org/apache/flink/flink-json/1.20.2/flink-json-1.20.2.jar

Flink SQL> CREATE TABLE my_source_table (
>     id INT,
>     json_data STRING
> ) WITH (
>     'connector' = 'datagen',
>     'rows-per-second' = '1',
>     'fields.id.kind' = 'sequence',
>     'fields.id.start' = '1',
>     'fields.id.end' = '10',
>     'fields.json_data.kind' = 'sequence',
>     'fields.json_data.start' = '{"name": "Alice", "age": 30}',
>     'fields.json_data.end' = '{"name": "Bob", "age": 25}'
> );
[INFO] Execute statement succeeded.

Flink SQL> CREATE TABLE my_parsed_table (
>     id INT,
>     user_name STRING,
>     user_age INT
> ) WITH (
>     'connector' = 'print'
> );
[INFO] Execute statement succeeded.

Flink SQL> INSERT INTO my_parsed_table
> SELECT
>     id,
>     parsed_json.name,
>     parsed_json.age
> FROM
>     my_source_table,
>     LATERAL TABLE(FROM_JSON(json_data, 'ROW<name STRING, age INT>')) AS
parsed_json;


*[ERROR] Could not execute SQL statement.
Reason:org.apache.calcite.sql.validate.SqlValidatorException: No match
found for function signature FROM_JSON(<CHARACTER>, <CHARACTER>)*

-- 
You have the obligation to inform one honestly of the risk, and as a person
you are committed to educate yourself to the total risk in any activity!

Once informed & totally aware of the risk,
every fool has the right to kill or injure themselves as they see fit!

Reply via email to