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.

https://github.com/prestodb/presto/blob/c73359fe2173e01140b7d5f102b286e81c1ae4a8/presto-docs/src/main/sphinx/release/release-0.75.rst


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -