-DATASET CSV empty

--

-CASE JsonExtractTestFromDuckDB

-LOAD_DYNAMIC_EXTENSION json
# should go to our NULL

-STATEMENT RETURN json_extract('{"foo": null}', '$.foo')
---- 1
null

-STATEMENT RETURN json_extract('{"foo": null}', '$.foo.bar')
---- 1

-STATEMENT RETURN json_extract(null, '0')
---- 1

-STATEMENT RETURN json_extract('[null]', '0')
---- 1
null

-STATEMENT RETURN json_extract('{"my_field": {"my_nested_field": ["goose", "kuzu"]}}', 'my_field/my_nested_field/1')
---- 1
"kuzu"

-STATEMENT RETURN json_extract('{"my_field": {"my_nested_field": ["goose", "kuzukuzukuzukuzu"]}}', 'my_field/my_nested_field/1')
---- 1
"kuzukuzukuzukuzu"

-STATEMENT RETURN json_extract('[1, 2, 42]', 2)
---- 1
42

# some sqlite tests

-STATEMENT RETURN json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$');
---- 1
{"a":2,"c":[4,5,{"f":7}]}


-STATEMENT RETURN json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c');
---- 1
[4,5,{"f":7}]


-STATEMENT RETURN json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c/2');
---- 1
{"f":7}


-STATEMENT RETURN json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.c/2/f');
---- 1
7


-STATEMENT RETURN json_extract('{"a":2,"c":[4,5,{"f":7}]}', '$.x');
---- ok

-STATEMENT RETURN json_extract('{"a":2,"c":[4,5],"f":7}', ['$.c','$.a']);
---- 1
[[4,5],2]


-STATEMENT RETURN json_extract('{"a":2,"c":[4,5,{"f":7}]}', ['$.x', '$.a']);
---- 1
[,2]

-STATEMENT RETURN json_extract(NULL, 2);
---- 1


-STATEMENT RETURN json_extract(NULL, '$.x');
---- 1

-STATEMENT RETURN json_extract(json_object("foo", "5"), "foo") = to_json("5");
---- 1
True

-STATEMENT RETURN json_extract(json_object("foo", "true"), "foo") = to_json("true");
---- 1
True

-STATEMENT UNWIND ['{"name": "pop", "age": 32}', '{"name": "alice"}', null] as t RETURN json_extract(t, 'name') = '"alice"'
---- 3

True
False
