登录    关于
马育民老师的博客

马育民的博客

QQ:65242847

hbase2.1.x shell scan SingleColumnValueFilter 过滤某列时,也必须查询该列,否则过滤条件不生效

描述问题

过滤条件中有 age,但只查询 name 列,所以查询过滤条件不生效

添加测试数据

put 'student2','1000','info:name','lilei'
put 'student2','1000','info:age','20'
put 'student2','1001','info:name','lucy'
put 'student2','1001','info:age','19'
put 'student2','1002','info:name','hanmeimei'
put 'student2','1002','info:age','23'

查询语句

scan 'student2',{FILTER => "SingleColumnValueFilter('info','age',>,'binary:20') AND SingleColumnValueFilter('info','age',<,'binary:22')",FORMATTER=>'toString',COLUMNS =>['info:name']}

解决

查询列中,加上 age 列即可

scan 'student2',{FILTER => "SingleColumnValueFilter('info','age',>,'binary:20') AND SingleColumnValueFilter('info','age',<,'binary:22')",FORMATTER=>'toString',COLUMNS =>['info:name','info:age']}

原文出处:http://malaoshi.top/show_1IX2JiyxsCB7.html