Module: ElasticGraph::Warehouse::SchemaDefinition::ObjectInterfaceAndUnionExtension

Defined in:
elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/object_interface_and_union_extension.rb

Overview

Instance Method Summary collapse

Instance Method Details

#to_warehouse_column_typeString

Note:

For union types, the STRUCT includes all fields from all subtypes, following the same pattern used in the datastore mapping (see SchemaDefinition::Indexing::FieldType::Union#to_mapping).

Returns the warehouse column type representation for this object, interface, or union type.

Returns:

  • (String)

    a STRUCT SQL type containing all subfields



23
24
25
26
27
28
29
30
31
32
# File 'elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/object_interface_and_union_extension.rb', line 23

def to_warehouse_column_type
  subfields = indexing_fields_by_name_in_index.values.map(&:to_indexing_field).compact

  struct_field_expressions = subfields.map do |subfield|
    warehouse_type = FieldTypeConverter.convert(subfield.type)
    "#{subfield.name} #{warehouse_type}"
  end.join(", ")

  "STRUCT<#{struct_field_expressions}>"
end