我想使用hiveql检查字符串是否包含任何特定字符?
我碰到了下面的那个。
find_in_set(str, strlist)这是正确的UDF使用吗?
例如,:
下面的列在值中包含"1“。
column1 = "test1String"我需要编写一个HiveQL,其中条件返回带有column1值的行包含1。
发布于 2016-07-01 13:38:33
int instr(string str, string substr)返回substr在str中第一次出现的位置。如果其中任何一个参数为null,则返回null;如果在str中找不到substr,则返回0。请注意,这不是基于零的。str中的第一个字符具有索引1。
select case when instr (column1, '1') >0 then 'contains' else 'not contains' end from ... 参考如下:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
也使用rlike
select case when column1 rlike '1' then 'contains' else 'not contains' end使用like
select case when column1 like '%1%' then 'contains' else 'not contains' end使用locate
select case when locate('1', column1) >0 then 'contains' else 'not contains' endhttps://stackoverflow.com/questions/38144215
复制相似问题