Class: Piglet::Relation::Cross

Inherits:
Object
  • Object
show all
Includes:
Relation
Defined in:
lib/piglet/relation/cross.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes included from Relation

#sources

Instance Method Summary collapse

Methods included from Relation

#[], #alias, #cogroup, #cross, #distinct, #eql?, #field, #filter, #foreach, #group, #hash, #join, #limit, #method_missing, #nested_foreach, #next_field_alias, #order, #sample, #split, #stream, #union

Constructor Details

#initialize(relations, interpreter, options = {}) ⇒ Cross

Returns a new instance of Cross.



8
9
10
11
# File 'lib/piglet/relation/cross.rb', line 8

def initialize(relations, interpreter, options={})
  options ||= {}
  @sources, @interpreter, @parallel = relations, interpreter, options[:parallel]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Piglet::Relation::Relation

Instance Method Details

#schemaObject



13
14
15
16
# File 'lib/piglet/relation/cross.rb', line 13

def schema
  schemas = @sources.map { |s| s.schema }
  schemas.first.union(schemas[1..-1])
end

#to_sObject



18
19
20
21
22
# File 'lib/piglet/relation/cross.rb', line 18

def to_s
  str  = "CROSS #{source_aliases.join(', ')}"
  str << " PARALLEL #{@parallel}" if @parallel
  str
end