Sha256: 83838d7a4b2d6dd8c3e08043314d032d46240f8f4d94f573d556ab185565a6d4

Contents?: true

Size: 698 Bytes

Versions: 1

Compression:

Stored size: 698 Bytes

Contents

# encoding: utf-8

module Piglet
  module Relation
    class Foreach # :nodoc:
      include Relation
    
      def initialize(relation, interpreter, field_expressions)
        @sources, @interpreter, @field_expressions = [relation], interpreter, [field_expressions].flatten
      end
      
      def schema
        description = @field_expressions.map { |expr| [expr.name, expr.type] }
        Piglet::Schema::Tuple.parse(description)
      end
    
      def to_s
        "FOREACH #{@sources.first.alias} GENERATE #{field_expressions_string}"
      end
    
    private
  
      def field_expressions_string
        @field_expressions.map { |fe| fe.to_s }.join(', ')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
piglet-0.3.0 lib/piglet/relation/foreach.rb