0

我正在运行以下失败的 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'))}

我没有得到错误。

4

1 回答 1

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
于 2017-02-23T07:09:33.357 回答