Module: Relationizer::BigQuery
- Defined in:
- lib/relationizer/big_query.rb
Defined Under Namespace
Classes: ReasonlessTypeError
Constant Summary collapse
- KNOWN_TYPES =
[:INT64, :FLOAT64, :STRING, :BOOL, :TIMESTAMP, :DATE]
- DEFAULT_TYPES =
-> (obj) { case obj when Integer then :INT64 when BigDecimal then :FLOAT64 when Float then :FLOAT64 when String then :STRING when TrueClass then :BOOL when FalseClass then :BOOL when Time then :TIMESTAMP when DateTime then :TIMESTAMP when Date then :DATE when Array then :ARRAY else nil end }
Instance Method Summary collapse
Instance Method Details
#create_relation_literal(schema, tuples) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/relationizer/big_query.rb', line 27 def create_relation_literal(schema, tuples) types = fixed_types(schema.values, tuples) _types_exp = types_exp(schema.keys, types) tuples_exp = tuples.map { |tuple| tuple.zip(types). map { |(col, type)| to_literal(col, type) }. join(", "). tap { |t| break "(#{t}#{', NULL' if tuple.length == 1})" } }.join(", ").tap { |t| break "[#{t}]"} select_exp = if schema.one? "#{schema.keys.first}" else '*' end "SELECT #{select_exp} FROM UNNEST(#{_types_exp}#{tuples_exp})" end |