Sha256: c7e4a9f7304a55d4e073cccc6b3f4b459265c5e379c5c31a24d1075bd176643a
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
# encoding: utf-8 module Piglet module Relation class Group # :nodoc: include Relation def initialize(relation, interpreter, grouping, options={}) options ||= {} @sources, @interpreter, @grouping, @parallel = [relation], interpreter, grouping, options[:parallel] end def schema parent = @sources.first parent_schema = parent.schema if @grouping.size == 1 group_type = parent.schema.field_type(@grouping.first) else group_type = Piglet::Schema::Tuple.parse( @grouping.map { |field| [field, parent_schema.field_type(field)] } ) end Piglet::Schema::Tuple.parse([ [:group, group_type], [parent.alias.to_sym, Piglet::Schema::Bag.new(parent_schema)] ]) end def to_s str = "GROUP #{@sources.first.alias} BY " if @grouping.size > 1 str << "(#{@grouping.join(', ')})" else str << @grouping.first.to_s end str << " PARALLEL #{@parallel}" if @parallel str end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
piglet-0.3.0 | lib/piglet/relation/group.rb |