QUERY:
my_issue_table a
CROSS JOIN UNNEST(JSON_QUERY(
a.itemsImpacted,
'$' WITH CONDITIONAL ARRAY WRAPPER
)) AS t (tag)
ERROR:
org.apache.flink.table.api.ValidationException: SQL validation failed. From line 3, column 12 to line 3, column 114: Cannot apply 'UNNEST' to arguments of type 'UNNEST(<VARCHAR(2147483647)>)'. Supported form(s): 'UNNEST(MULTISET)' 'UNNEST(ARRAY)' 'UNNEST(MAP)' UNNEST(MULTISET) UNNEST(ARRAY) UNNEST(MAP)
https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/dev/table/functions/systemfunctions/#json-functions
according to the documentation JSON_QUERY should return an array but it is still a varchar. FLINK version 1.16.1
am i missing something?
m
Martijn Visser
01/09/2024, 4:35 PM
The return type of JSON_QUERY is always returned as a STRING, but you can't UNNEST a STRING
✅ 1
t
Tuan Le
01/11/2024, 12:05 AM
I ran into similar situation. I wrote a UDF to deserialize STRING to Array and pass that to UNNEST
m
Martijn Visser
01/11/2024, 1:41 PM
I think the best solution would be to add support for RETURNING to the JSON_QUERY function