我想使用HiveQL UDF来检查字符串是否包含任何特定字符?
我找到了下面的方法。
find_in_set(str, strlist)
这是正确的UDF使用方法吗?
例如:
下面的列中包含值为"1"。
column1 = "test1String"
我需要编写一个HiveQL where条件,以返回列1值包含1的行。
int instr(string str, string substr)
返回str中第一次出现substr的位置。如果任意一个参数为null,则返回null,如果在str中找不到substr,则返回0。请注意,这不是基于0的索引。在str中的第一个字符索引为1。
select case when instr (column1, '1') >0 then 'contains' else 'not contains' end from ...
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' end
where column1 rlike '[1]'
- sumitya