The JSON_EXISTS predicate determines whether JSON data contains a JSON value that can be located by using the specified sql-json-path-expression.
Posible Workarounds for JSON_EXISTS support below.
-- DB2 sql-json-path-expression to SnowFlake SQL
-- CREATE THE DEMO TABLE
create or replace table person (v variant);
-- POPULATE TABLE
insert into person select parse_json ('{ "isbn": "123-456-222", "author": [ { "name":"Jones"},{"name":"Smith"}]}');
-- QUERY TABLE
select
*
from
person
;
select
v:isbn -- $.isbn
, v:author[0].name -- $.author[0].name
, v:author[1].name -- $.author[1].name
from person
;
-- RECREATE THE DEMO TABLE FOR ANOTHER EXAMPLE
create or replace table person (v variant);
-- POPULATE TABLE
insert into person select parse_json ('{
"person" : {"firstname":"Fred", "lastname":"Gauss"},
"where" : "General Products",
"friends" : [ { "name": "Lili","rank": 5 }, {"name": "Hank", "rank": 7} ],
"work.area": "Finance"
}');
-- QUERY TABLE
select
*
from
person
;
select
v:person:lastname -- $.person.lastname
, v:friends -- $.friends
, v:person:firstname -- $.*.firstname [not equal]
, v:person -- $.person.* [not equal]
, v:friends -- $.friends[*]
, CONCAT(v:friends[0]:rank, ', '
, v:friends[1]:rank) -- $.friends[*].rank [not equal]
, v:work.area -- $.work.area
, v:"work.area" -- $.work\.area
from person
;
-- THIS IS A WORKAROUND FOR * WILDCARD, TO RETURN SEPARATED (FLATTEN) VALUES FROM AN ARRAY
select
value:rank -- $.friends[*].rank
from
person
, lateral flatten( input => v:friends )
;
// DROP TABLE
DROP TABLE person
;