【问题标题】:Is it possible to skip loading a row using the kiba-etl gem?是否可以使用 kiba-etl gem 跳过加载行?
【发布时间】:2015-10-01 16:36:12
【问题描述】:

如果我认为使用 kiba-etl gem 的行无效,是否可以跳过加载某些行?

例如,如果在将其加载到系统之前必须通过验证或发生错误,并且在记录问题时我仍然需要将数据推送到 sys 中。

【问题讨论】:

    标签: kiba-etl


    【解决方案1】:

    这里是木场的作者!要从管道中删除一行,只需在转换结束时返回 nil

    transform do |row|
      row_valid = some_custom_operation
      row_valid ? row : nil
    end
    

    您还可以“写下”有问题的行,并在以后使用这样的 post_process 块报告它们(在这种情况下,需要中等到少量的虚假行):

    @bogus_row_ids = []
    
    transform do |row|
      # SNIP
      if row_valid(row)
        row
      else
        @bogus_row_ids << row[:id]
        nil # remove from pipeline
      end
    end
    
    post_process do
      # do something with @bogus_row_ids, send an email, write a file etc
    end
    

    让我知道这是否正确回答了您的问题,或者您是否需要更精确的答案。

    【讨论】:

      【解决方案2】:

      我很笨。我意识到你可以在转换/加载过程中发现你的错误并返回 nil。

      【讨论】:

      • 请不要责备自己 :-) 这是一种可能性 - 我在单独的答案中添加了更多想法,如果这正确回答了问题,请告诉我,其他人也可能有!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      • 2017-10-06
      相关资源
      最近更新 更多