JSON_VALUE UDF
Translation reference to convert Oracle JSON_VALUE function to Snowflake
Description
As per Oracle's documentation, this function uses the SQL/JSON Path Expression to request information about a portion of a JSON instance. The returning value is always a scalar value, else the function returns NULL
by default.
The JSON_VALUE_UDF is a Snowflake implementation of the JSONPath specification that uses a modified version of the original JavaScript implementation developed by Stefan Goessner.
Sample Source Patterns
Setup Data
Run these queries to run queries in the JSON_VALUE Patterns section.
Oracle
Snowflake
JSON_VALUE Patterns
Oracle
Snowflake
Known Issues
1. Returning Type Clause is not fully supported
Now, the only supported types when translating the functionality of the RETURNING TYPE clause are VARCHAR2
, CLOB
and NUMBER
.
For all the other types supported by the original JSON_VALUE function, the JSON_VALUE_UDF will behave as if no RETURNING TYPE clause was specified.
Unsupported types:
DATE
TIMESTAMP [WITH TIME ZONE]
SDO_GEOMETRY
CUSTOM TYPE
2. ON MISMATCH Clause is not supported
Now, the ON MISMATCH clause is not supported, and a warning EWI is placed instead. Thus, the translated code will behave as if no ON MISMATCH clause was originally specified.
3. Complex filters are not supported
Complex filters with more than one expression will return null as they are not supported.
For example, with the same data as before, this JSON path $.store.book[*]?(@.category == "reference").title
is supported and will return 'Sayings of the Century'
.
However, $.store.book[*]?(@.category == "reference" && @.price < 10).title
will return null
since more than one expression is used in the filter.
Related EWIs
Last updated