Cannot extract Json value from json column #22800
-
Hello! Having column value {"birth_date": {"$date": "2024-06-13T06:06:04.964Z"}} of type JSON I want to extract value of key $date in SELECT statement using Trino JSON functions. You can reproduce my use case usind docker: docker exec -it trino trino
Every query returns error, please suggest right way to accomplish my task - extract JSON object value from my example JSON. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
For
|
Beta Was this translation helpful? Give feedback.
For
json_extract
/json_extract_scalar
, you need to change the JSON path to$.birth_date["$date"]
. It doesn't support quoted path elements.json_query
doesn't yet support JSON type as input. It needs to operate on a VARCHAR. To get around that limitation, you can first convert the JSON value to VARCHAR viajson_format
: