class Dataflow::Nodes::Filter::WhereNode

Select records that match the condition.

Constants

VALID_OPS

Private Instance Methods

compute_batch(records:) click to toggle source
# File lib/dataflow/nodes/filter/where_node.rb, line 18
def compute_batch(records:)
  where(records: records)
end
where(records:) click to toggle source
# File lib/dataflow/nodes/filter/where_node.rb, line 22
def where(records:)
  tokens = record_dig_tokens(key: key, use_sym: dependencies.first.use_symbols?)
  case op.to_s.downcase
  when 'eq'
    records.select { |x| x.dig(*tokens) == value }
  when 'ne'
    records.select { |x| x.dig(*tokens) != value }
  when 'le'
    records.select { |x| x.dig(*tokens) <= value }
  when 'lt'
    records.select { |x| x.dig(*tokens) < value }
  when 'ge'
    records.select { |x| x.dig(*tokens) >= value }
  when 'gt'
    records.select { |x| x.dig(*tokens) > value }
  else
    raise Errors::InvalidConfigurationError, "Invalid op key: #{op}"
  end
end