需求:
有表 flow_table (host,request_path, cnt)
需要用hiveSQL过滤表中 request_path不含数字的host和request;
方法:
使用hive中 RLIKE 这个关键字
介绍:
RLIKE 子句是 Hive 中这个功能的一个扩展, 其可以通过 Java 的正则表达式这个更强大的语言来指定匹配条件
具体操作:
select host, request_path from flow_table where not (request_path Rlike ‘[0-9]’ );
即可得到不含数字的request_path;
扩展需求:
request_path不含数字 但是包含v1,v2,v3等的request_path保留
操作:
select host, request_path from flow_table where not (request_path Rlike ‘[0-9]’ and not (request_path Rlike ‘v[0-9]’));
Rlike后面可以的正则非常强大,等待你们的探索。