sql优化-json字符串数组解析优化-doris

sql优化-json字符串数组解析优化-doris


data字段数据样式:
[{“key”:“pen_id”,“value”:“754284934366130203”},{“key”:“distance_fault”,“value”:“[0,0,0,0,0,0,0,0,0,0]”},{“key”:“camera_0_fault”,“value”:“[0,0,0,0,0,0,0,0,0,0]”},{“key”:“animal_yingzi_id”,“value”:“1900-0bb292e51dcae281”},{“key”:“camera_1_fault”,“value”:“[0,0,0,0,0,0,0,0,0,0]”},{“key”:“animal_id”,“value”:“1018973536930246656”},{“key”:“global_fault”,“value”:“[0,0,0,0,0,0]”},{“key”:“hard_fault”,“value”:“[0,0,0,0,0,0,0,0,0,0]”},{“key”:“ai_status”,“value”:“[0,0,0,0,0,0]”},{“key”:“animal_version”,“value”:“1676017220430”}]

doris 1.1 版本 json 函数解析:
get_json_string(data,CONCAT(‘$.[’,nums.id-1,‘].key’))

优化:使用正则解析
regexp_extract(DATA,‘“key”:“animal_yingzi_id”,“value”:“(.*?)”’,1)

doris 基于内存计算,底表2023.1.1 - 2023.3.20号近80天数据量:52750528,doris json解析执行超时,正则解析1min15s

你可能感兴趣的:(doris,doris,json,sql)