insert overwrite table ... partition(platform_id)selectif(user_id regexp('.*:.*'),user_id,concat(platform_id,':',user_id)) asuser_id,...,last_onlined_at,created_at,rating_score,updated_at,noise,platform_id from `XXX`;
concat
concat(platform_id,':',user_id)) as
user_id
concat拼接别名为user_id
if
if()相当于三目运算符
if(条件表达式,后果1,后果2)相当于java中的三目运算符,只是if前面的表达式类型能够不一样。
if中的等于条件用“=”或“==”均可
REGEXP_EXTRACT
regexp_extract(string A, string pattern, int index)
返回值: string
阐明:将字符串A依照pattern正则表达式的规定拆分,返回index指定的字符,index从1开始计。
REGEXP_REPLACE
语法: regexp_replace(string A, string B, string C)
操作类型: strings
返回值: string
阐明: 将字符串A中的合乎java正则表达式B的局部替换为C。
hive> select regexp_replace('h234ney', '\\d+', 'o');OKhoney