Module: ElasticGraph::Warehouse::SchemaDefinition::APIExtension

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

Overview

Module designed to be extended onto an SchemaDefinition::API instance to add Data Warehouse configuration generation capabilities.

To use this module, pass it in schema_definition_extension_modules when defining your Local::RakeTasks.

Examples:

Define local rake tasks with this extension module

require "elastic_graph/warehouse/schema_definition/api_extension"

ElasticGraph::Local::RakeTasks.new(
  local_config_yaml: "config/settings/local.yaml",
  path_to_schema: "config/schema.rb"
) do |tasks|
  tasks.schema_definition_extension_modules = [
    ElasticGraph::Warehouse::SchemaDefinition::APIExtension
  ]
end

Constant Summary collapse

COLUMN_TYPES_BY_BUILT_IN_SCALAR_TYPE =

Maps built-in ElasticGraph scalar types to their warehouse column types.

{
  "Boolean" => "BOOLEAN",
  "Cursor" => "STRING",
  "Date" => "DATE",
  "DateTime" => "TIMESTAMP",
  "Float" => "DOUBLE",
  "ID" => "STRING",
  "Int" => "INT",
  "JsonSafeLong" => "BIGINT",
  "LocalTime" => "STRING",
  "LongString" => "BIGINT",
  "String" => "STRING",
  "TimeZone" => "STRING",
  "Untyped" => "STRING"
}.freeze

Class Method Summary collapse

Class Method Details

.extended(api) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Extends the API with warehouse functionality when this module is extended.

Parameters:



59
60
61
62
63
64
65
66
67
68
# File 'elasticgraph-warehouse/lib/elastic_graph/warehouse/schema_definition/api_extension.rb', line 59

def self.extended(api)
  api.factory.extend FactoryExtension

  api.on_built_in_types do |type|
    case type
    when ScalarTypeExtension
      type.warehouse_column type: COLUMN_TYPES_BY_BUILT_IN_SCALAR_TYPE.fetch(type.name)
    end
  end
end