sql - Issues with JSON_EXTRACT in Presto for keys containing ' ' character -
i'm using presto(0.163) query data , trying extract fields json.
i have json 1 given below, present in column 'style_attributes':
"attributes": { "brand fit name": "regular fit", "fabric": "cotton", "fit": "regular", "neck or collar": "round neck", "occasion": "casual", "pattern": "striped", "sleeve length": "short sleeves", "tshirt type": "t-shirt" }
i'm unable extract field 'short sleeves'. below query i'm using:
select json_extract(style_attributes,'$.attributes.sleeve length') length table;
the query fails following error- invalid json path: '$.attributes.sleeve length'
for fields without ' '(space), query running fine.
i tried find resolution in presto documentation, no success.
presto:default> select json_extract_scalar('{"attributes":{"sleeve length": "short sleeves"}}','$.attributes["sleeve length"]'); _col0 --------------- short sleeves
or
presto:default> select json_extract_scalar('{"attributes":{"sleeve length": "short sleeves"}}','$["attributes"]["sleeve length"]'); _col0 --------------- short sleeves
json function changes
the :func:
json_extract
, :func:json_extract_scalar
functions support square bracket syntax:select json_extract(json, '$.store[book]'); select json_extract(json,'$.store["book name"]');
as part of change, set of characters allowed in non-bracketed path segment has been restricted alphanumeric, underscores , colons. additionally, colons cannot used in un-quoted bracketed path segment. use new bracket syntax quotes match elements contain special characters.
Comments
Post a Comment