当前位置: 首页 > 工具软件 > Extract > 使用案例 >

bigquery json处理函数json_extract和json_extract_scalar的区别

郭云
2023-12-01

json_extract(json_expression, json_path)将返回所有 JSON 值

json_extract_scalar(json_expression, json_path)将只返回标量值(字符串、数字、布尔值)

我们用案例来看下两者之间的区别

解析数据格式:

{"total":"5","success":"1","translate_status":"0","success_pos_list":"4","fail_pos_list":"0,1,2,3","batch_id":"2022120100"}

解析sql

select 
json_extract_scalar(xx_info,'$.translate_status') as scalar_translate_status,
json_extract(xx_info,'$.translate_status') as extract_translate_status

from  edw.scratch.table
scalar_translate_statusextract_translate_status
0“0”
 类似资料: