【问题标题】:Why is pig filtering out empty string despite not asking it to?为什么猪尽管没有要求它过滤掉空字符串?
【发布时间】:2017-03-29 17:00:29
【问题描述】:

我正在尝试使用 pig 过滤器方法过滤掉数据。但是我不想过滤掉空字符串。以下过滤器正在过滤掉我想要的东西,但它也过滤掉了(动作匹配'')我没有要求它。有什么办法吗?

filtered = filter distinctVals by not ((action matches 'Identified') or (action matches 'Initiated') or (action matches 'Completed'));

【问题讨论】:

  • 我希望它只排除这 3 个动作。但是,如果操作是空字符串,它也被排除在外。
  • 如果答案有用,您可以点击向上箭头。如果它解决了您的问题,您可以单击复选标记图标。

标签: filter apache-pig hdfs


【解决方案1】:

过滤器不像“过滤掉”那样工作。他们通过“过滤”工作。

您可以从example 中看到这一点。过滤结果

filter_data = FILTER student_details BY city == 'Chennai';

只是拥有钦奈的物品:

(6,Archana,Mishra,23,9848022335,Chennai)
(8,Bharathi,Nambiayar,24,9848022333,Chennai)

因此,您的代码应排除 not:

filtered = filter distinctVals by ((action matches 'Identified') or (action matches 'Initiated') or (action matches 'Completed'));

【讨论】:

  • 好的,所以我尝试“过滤”但是我无法过滤空字符串。过滤=过滤 distinctVals ((动作匹配'错误')或(动作匹配'失败')或(动作匹配''));不包括我的空字符串结果
  • @Pxl: 然后使用== 而不是matchesmatches 将是一个正则表达式。
猜你喜欢
  • 1970-01-01
  • 2022-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-21
  • 1970-01-01
相关资源
最近更新 更多