Class: Iceberg::TableDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/iceberg/table_definition.rb

Constant Summary collapse

TYPES =
%w[
  boolean int long float double date timestamp timestamptz string uuid binary
]
TYPE_ALIASES =
{
  "integer" => "int",
  "bigint" => "long"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTableDefinition

Returns a new instance of TableDefinition.



14
15
16
# File 'lib/iceberg/table_definition.rb', line 14

def initialize
  @fields = []
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



12
13
14
# File 'lib/iceberg/table_definition.rb', line 12

def fields
  @fields
end

Instance Method Details

#column(name, type, null: true, default: nil, comment: nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/iceberg/table_definition.rb', line 24

def column(name, type, null: true, default: nil, comment: nil)
  type = type.to_s
  @fields << {
    id: @fields.size + 1,
    name: name.to_s,
    type: TYPE_ALIASES.fetch(type, type),
    required: !null,
    doc: comment,
    # no need for initial default (and not supported until v3)
    write_default: default
  }
end