上云无忧 > 文档中心 > 百度数据仓库 Palo SQL语法手册 - JSON解析函数
百度数据仓库 Palo Doris版
百度数据仓库 Palo SQL语法手册 - JSON解析函数

文档简介:
PALO 目前支持3个 JSON 解析函数: 1.get_json_int 2.get_json_string 3.get_json_double GET_JSON_INT Description: get_json_int(VARCHAR json_str, VARCHAR json_path)
*此产品及展示信息均由百度智能云官方提供。免费试用 咨询热线:400-826-7010,为您提供专业的售前咨询,让您快速了解云产品,助您轻松上云! 微信咨询
  免费试用、价格特惠

PALO 目前支持3个 JSON 解析函数:

1.get_json_int
2.get_json_string
3.get_json_double

GET_JSON_INT

Description

get_json_int(VARCHAR json_str, VARCHAR json_path)
  • 功能:解析并获取 JSON 字符串内指定路径的整型内容。其中第一个参数为json字符串,第二个参数为json内的路径。json_path 必须以 $ 符号作为开头,使用 . 作为路径分割符。如果路径中包含 .,则可以使用双引号包围。 使用 [] 表示数组下标,从0开始。path 的内容不能包含 ", [, ]。 如果 json_string 格式不对,或 json_path 格式不对,或无法找到匹配项,则返回 NULL。
  • 返回类型:int类型或NULL。

Example

mysql> select get_json_int('{"col1":100, "col2":"string", "col3":1.5}', 
"$.col1"); +-----------------------------------------------------------
----------+ | get_json_int('{"col1":100, "col2":"string", "col3":1.5}', '$.col1') | +-----
----------------------------------------------------------------+ | 100 | +---------------
------------------------------------------------------+

Keywords

GET_JSON_INT, JSON

GET_JSON_STRING

Description

get_json_string(VARCHAR json_str, VARCHAR json_path)
  • 功能:解析并获取 JSON 字符串内指定路径的字符串内容。 其中 json_path 必须以 $ 符号作为开头,使用 . 作为路径分割符。如果路径中包含 .,则可以使用双引号包围。 使用 [] 表示数组下标,从0开始。path 的内容不能包含 ",[,]。 如果 json_string 格式不对,或 json_path 格式不对,或无法找到匹配项,则返回 NULL。
  • 返回类型:string类型或NULL。

Example

mysql> select get_json_string('{"col1":100, "col2":"string", "col3":1.5}', "$.col2"); +-----------
-------------------------------------------------------------+ | get_json_string('{"col1":100, "col2":"string", 
"col3":1.5}', '$.col2') | +----------------------------------------------------------------------
--+ | string | +------------------------------------------------------------------------+

Keywords

GET_JSON_STRING, JSON

GET_JSON_DOUBLE

Description

get_json_double(VARCHAR json_str, VARCHAR json_path)
  • 功能:解析并获取 JSON 字符串内指定路径的浮点型内容。其中 json_path 必须以 $ 符号作为开头,使用 . 作为路径分割符。如果路径中包含 .,则可以使用双引号包围。 使用 [] 表示数组下标,从0开始。path 的内容不能包含 ",[,]。 如果 json_string 格式不对,或 json_path 格式不对,或无法找到匹配项,则返回 NULL。
  • 返回类型:double类型或NULL。

Example

mysql> select get_json_double('{"col1":100, "col2":"string", "col3":1.5}', "$.col3"); +-------------------------
-----------------------------------------------+ | get_json_double('{"col1":100, "col2":"string", "col3":1.5}', 
'$.col3') | +------------------------------------------------------------------------+ | 1.5 | +------------------
------------------------------------------------------+ mysql> select get_json_double('{"col1":100, "col2":"string",
 "col3":1.5}', "$.col5"); +----------------------------------------------------------------------
--+ | get_json_double('{"col1":100, "col2":"string", "col3":1.5}', '$.col5') | +-------------------------
-----------------------------------------------+ | NULL | +-------------------------------------------
-----------------------------+

Keywords

GET_JSON_DOUBLE, JSON

相似文档
  • PALO 支持以下位操作函数: 1.bitand 2.bitnot 3.bitor 4.bitxor BITAND Desciption: bitand(integer_type a, same_type b) 功能:按位与运算 返回类型: 和输入类型相同
  • PALO支持的哈希函数如下: 1.murmur_hash3_32 MURMUR_HASH3_32 Description: INT MURMUR_HASH3_32(VARCHAR input, ...) 功能:返回输入字符串的32位murmur3 hash值 返回类型:string类型
  • PALO支持的字符串函数如下: 1.append_trailing_char_if_absent 2.ascii 3.concat 4.concat_ws 5.ends_with 6.find_in_set 7.group_concat 8.instr 9.length,char_length,character_length 10.locate 11.lower,lcase 12.lpad 13.ltrim 14.money_format 15.null_or_empty 16.parse_url 17.regexp_extract 18.regexp_replace 19.repeat 20.replace 21.reverse 22.rpad 23.rtrim 24.space 25.split_part 26.starts_with 27.strleft,left 28.strright,right 29.substr,substring 30.trim 31.upper,ucase
  • PALO 支持以下数学函数: 1.sin 2.asin 3.tan 4.atan 5.cos 6.acos 7.abs 8.bin 9.ceil 10.floor 11.conv 12.degrees 13.e 14.exp 15.mod 16.fmod 17.pmod 18.greatest 19.least 20.hex 21.unhex 22.ln 23.dlog1 24.log 25.negative 26.positive 27.pi 28.pow 29.radians 30.rand 31.round 32.sign 33.sqrt 34.truncate
  • PALO 支持的条件函数如下: 1.case 2.coalesce 3.if 4.ifnull 5.nullif
官方微信
联系客服
400-826-7010
7x24小时客服热线
分享
  • QQ好友
  • QQ空间
  • 微信
  • 微博
返回顶部