0
我有一个红移表“人”在特定的列有数据像这样字符串匹配
[{"attributeName":"name","attributeMetadata":null,"attributeValue":"KitchenAid - 7-Speed Hand Mixer - White","attributeImageType":"PRODUCT","attributeStatusCodes":[]},
{"attributeName":"title","attributeMetadata":null,"attributeValue":"KitchenAid","attributeImageType":"PRODUCT","attributeStatusCodes":[]},
{"attributeName":"address","attributeMetadata":null,"attributeValue":"address","attributeImageType":"PRODUCT","attributeStatusCodes":[]},
{"attributeName":"PIN CODE","attributeMetadata":null,"attributeValue":"32110","attributeImageType":"IMG","attributeStatusCodes":[]}]
我想只提取字典/ JSON /含PIN CODE
子(见下文)
{"attributeName":"PIN CODE","attributeMetadata":null,"attributeValue":"32110","attributeImageType":"IMG","attributeStatusCodes":[]}
我尝试以下查询,它给了以下错误
select distinct regexp_substr(attributes,'.*({.*?"attributeName":"PIN CODE".*?}).*') from person ;
ERROR: Invalid content of repeat range
DETAIL:
-----------------------------------------------
error: Invalid content of repeat range
code: 8002
context: T_regexp_init
query: 528401
location: funcs_expr.cpp:130
process: query2_40 [pid=12603]
-----------------------------------------------
我猜这个问题是由于单个列中有多个attributeName
而发生的。他们是达到预期结果的一种方式。
你应该逃避花括号'\ {',否则它假定为像'\ W一个量词{ 2,5}'。这就是为什么它会抛出错误'“重复范围的无效内容”' – Mariano
@Mario抱歉没有工作,得到了相同的错误 –
任何机会,你可以创建一个小提琴? – Mariano