检测到您已登录华为云国际站账号,为了您更好的体验,建议您访问国际站服务网站 https://www.huaweicloud.com/intl/zh-cn
不再显示此消息
示例代码 去除字符串 yxabcxx 的右边空格。命令示例如下。 返回字符串 yxabcxx。 select rtrim('yxabcxx '); 等效于如下语句。 select trim(trailing from ' yxabcxx '); 去除字符串yxabcxx右端所有字符都在集合xy中的子串。
substring_index substring_index函数用于截取字符串str第count个分隔符之前的字符串。如果count为正,则从左边开始截取。如果count为负,则从右边开始截取。 命令格式 substring_index(string <str>, string
str值为NULL时,返回NULL。 示例代码 返回字符串ABC第一个字符的ASCII码。命令示例如下。 返回97。 select ascii('ABC'); 输入参数为NULL。命令示例如下。 返回NULL。 select ascii(null); 父主题: 字符串函数
BIGINT 用于指定空格数量。 返回值说明 返回STRING类型。 n为空时,返回报错。 n值为NULL时,返回NULL。 示例代码 返回6。 select length(space(6)); 父主题: 字符串函数
soundex函数用于从str返回一个soundex字符串,如soundex('Miller')= M460。 命令格式 soundex(string <str>) 参数说明 表1 参数说明 参数 是否必选 参数类型 说明 str 是 STRING 待转换的字符串。 返回值说明 返回STRING类型的值。
5版本及以前版本:regexp_replace函数用于将source字符串中匹配pattern的子串替换成指定字符串replace_string后,返回结果字符串。 Spark3.1.1版本:regexp_replace函数用于将source字符串中第occurrence次匹配pattern的子串
regexp_extract REGEXP_EXTRACT函数用于将字符串source按照pattern的分组规则进行字符串匹配,返回第groupid个组匹配到的字符串内容。 命令格式 regexp_extract(string <source>, string <pattern>[
reverse reverse函数用于返回倒序字符串。 命令格式 reverse(string <str>) 参数说明 表1 参数说明 参数 是否必选 参数类型 说明 str 是 STRING 如果输入为BIGINT、DOUBLE、DECIMAL或DATETIME类型,则会隐式转换为STRING类型后参与运算。
A、B 是 STRING 计算Levenshtein距离需要输入的字符串。 返回值说明 返回INT类型的值。 示例代码 返回3 SELECT levenshtein('kitten','sitting'); 父主题: 字符串函数
substr/substring substr、substring函数用于返回字符串str从start_position开始,长度为length的子串。 命令格式 substr(string <str>, bigint <start_position>[, bigint <length>])
translate translate函数用于将input字符串中的所出现的字符或者字符串from用字符或者字符串to替换。 例如:将abcde中的bcd替换成BCD。 translate("abcde", "bcd", "BCD") 命令格式 translate(string|char|varchar
concat_ws concat_ws函数用于连接多个字符串,字符串之间以指定的分隔符分隔。 命令格式 concat_ws(string <separator>, string <str1>, string <str2>[,...]) 或 concat_ws(string <separator>
示例代码 去除字符串" abc"的左边空格。命令示例如下。 返回字符串abc 。 select ltrim(' abc'); 等效于如下语句。 select trim(leading from ' abc'); leading代表去除字符串前面的空格 输入参数为NULL。命令示例如下。
upper/ucase upper函数用于从将文本字符串转换成字母全部大写的形式。 命令格式 upper(string A) 或 ucase(string A) 参数说明 表1 参数说明 参数 是否必选 参数类型 说明 A 是 STRING 待转换的文本字符串。 返回值说明 返回STRING类型。
DATETIME类型时,返回报错。 str或trimChars值为NULL时,返回NULL。 示例代码 去除字符串 yxabcxx 的左右空格。命令示例如下。 返回字符串yxabcxx。 select trim(' yxabcxx '); 等效于如下语句。 select trim(both
string <str2>) 参数说明 表1 参数说明 参数 是否必选 参数类型 说明 str1、str2 是 STRING 待计算的字符串str1、str2。 返回值说明 返回BIGINT类型。 str1或str2值为NULL时,返回NULL。 示例代码 返回3。 select
regexp_replace1 regexp_replace1函数用于将source字符串中第occurrence次匹配pattern的子串,替换成指定字符串replace_string后,返回结果字符串。 regexp_replace1函数只适用于Spark 2.4.5及之前的版本。
com:666/over/there/index.dtb?type=animal&name=narwhal#nose', 'USERINFO'); 父主题: 字符串函数
for [],返回整个数组。*不支持转义。 返回值说明 返回STRING类型的值。 如果json为空或非法的json格式,返回NULL。 如果json合法,path也存在,则返回对应字符串。 示例代码 提取JSON对象src_json.json中的信息。命令示例如下。 jsonString
instr1 instr1函数用于计算子串str2在字符串str1中的位置。 相似函数:instr,instr函数用于返回substr在str中最早出现的下标。但是instr不支持指定起始搜索位置和匹配次数。 命令格式 instr1(string <str1>, string <str2>[