OiO.lk Blog SQL What's the right way to cast ARRAY to JSON in Trino
SQL

What's the right way to cast ARRAY to JSON in Trino


I tried

select 
  json_format(cast(COALESCE(array_of_row, array[]) as JSON))
from my table

and it appears to work, but the trino documentation says that both JSON type and json_format are considered deprecated:

The following functions and operators are not compliant with the SQL standard, and should be considered deprecated. According to the SQL standard, there shall be no JSON data type. Instead, JSON values should be represented as string values. The remaining functionality of the following functions is covered by the functions described previously.

on https://trino.io/docs/current/functions/json.html#cast-to-json, so what’s the proper alternative way to do the same?



You need to sign in to view this answers

Exit mobile version