Sha256: 30c8722382dd60911dab3433fd283815992098cc6de4553d836c80838e5bddd5

Contents?: true

Size: 639 Bytes

Versions: 4

Compression:

Stored size: 639 Bytes

Contents

module Piglet
  module Relation
    class Foreach # :nodoc:
      include Relation
    
      def initialize(relation, field_expressions)
        @sources, @field_expressions = [relation], [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

4 entries across 4 versions & 1 rubygems

Version Path
piglet-0.2.4 lib/piglet/relation/foreach.rb
piglet-0.2.3 lib/piglet/relation/foreach.rb
piglet-0.2.2 lib/piglet/relation/foreach.rb
piglet-0.2.0 lib/piglet/relation/foreach.rb