我正在运行以下失败的HBASE shell脚本,我无法弄清楚原因:
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
a = ARGV[0]
myscan="'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('" + a + "'))}" + "\n"
scan myscan
exit
dcqa_event_agg行存在。当我运行命令时:
hbase shell filtertest.rb 2013
我收到以下错误:
ERROR: Unknown table 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))}
当我直接在HBASE shell中运行脚本时,它可以正常工作。有什么想法吗?
我在shell脚本中添加了一些调试:
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
a = ARGV[0]
myscan="'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('" + a + "'))}"
print myscan + "\n"
print "scan " + myscan + "\n"
scan myscan
exit
这是输出:
[test ~]$ hbase shell filtertest.rb 2013
13/08/23 18:08:44 WARN conf.Configuration: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))}
scan 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))}
ERROR: Unknown table 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))}!
删除引号并没有解决问题。
如果我在hbase shell环境中运行命令:
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
scan 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))}
我没有收到错误。
答案 0 :(得分:0)
第二个参数是Hash
,而不是String
。
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
a = ARGV[0]
scan 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('#{a}'))}
exit