字符串:
1.concat对于字符串进行拼接
concat(str1, str2, …, strN) - Returns the concatenation of str1, str2, …, strN.
Examples:> SELECT concat(‘Spark’, ‘SQL’); SparkSQL
2.concat_ws在拼接的字符串中间添加某种格式
concat_ws(sep, [str | array(str)]+) - Returns the concatenation of the strings separated by sep.
Examples:> SELECT concat_ws(’ ', ‘Spark’, ‘SQL’); Spark SQL
3.decode转码
decode(bin, charset) - Decodes the first argument using the second argument character set.
Examples: > SELECT decode(encode(‘abc’, ‘utf-8’), ‘utf-8’); abc
4.encode设置编码格式
encode(str, charset) - Encodes the first argument using the second argument character set.
Examples: > SELECT encode(‘abc’, ‘utf-8’);abc
5.format_string/printf 格式化字符串
format_string(strfmt, obj, …) - Returns a formatted string from printf-style format strings.
Examples:> SELECT format_string(“Hello World %d %s”, 100, “days”); Hello World 100 days
6.initcap将每个单词的首字母变为大写,其他字母小写; lower全部转为小写,upper大写
initcap(str) - Returns str with the first letter of each word in uppercase. All other letters are in lowercase. Words are delimited by white space.
Examples:> SELECT initcap(‘sPark sql’); Spark Sql
7.length返回字符串的长度
Examples:> SELECT length('Spark SQL '); 10
8.levenshtein编辑距离(将一个字符串变为另一个字符串的距离)
levenshtein(str1, str2) - Returns the Levenshtein distance between the two given strings.
Examples:> SELECT levenshtein(‘kitten’, ‘sitting’); 3
9.lpad返回固定长度的字符串,如果长度不够,用某种字符补全,rpad右补全
lpad(str, len, pad) - Returns str, left-padded with