【问题标题】:row_prefix in happybase table.scan not working with str variablehappybase table.scan 中的 row_prefix 不适用于 str 变量
【发布时间】:2016-11-14 03:34:38
【问题描述】:

我使用 table.scan 方法中的 row_prefix 来过滤行。问题是该函数在使用字符串文字时起作用。但是,如果使用变量,则不会返回任何数据。

例如,下面的代码是有效的

connection = happybase.Connection(connect string)
table = connection.table('table')
table = table.scan(row_prefix='abc001', include_timestamp=False)

但是下面的代码没有返回任何数据

connection = happybase.Connection(connect string)
table = connection.table('table')

query = '\'{0}{1}\''.format(args['str1'], args['str2'])
table = table.scan(row_prefix=query, include_timestamp=False)

第二种情况没有错误。

【问题讨论】:

  • 在传递给扫描之前尝试打印“查询”的值。你得到的值与第一个查询相同吗?
  • 是的,查询字符串是正确的。事实上,我把生成的字符串复制到scan方法中就可以了

标签: python hbase happybase


【解决方案1】:

将查询值中的'\'{0}{1}\'' 替换为'{0}{1}' 并重试

【讨论】:

  • 它在建议的格式更改后工作。谢谢!
猜你喜欢
  • 1970-01-01
  • 2018-08-22
  • 2015-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-04
  • 1970-01-01
相关资源
最近更新 更多