Class: ClickHouse::Definition::Column
- Inherits:
-
Object
- Object
- ClickHouse::Definition::Column
- Defined in:
- lib/click_house/definition/column.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#extensions ⇒ Object
Returns the value of attribute extensions.
-
#low_cardinality ⇒ Object
Returns the value of attribute low_cardinality.
-
#materialized ⇒ Object
Returns the value of attribute materialized.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nullable ⇒ Object
Returns the value of attribute nullable.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #extension_type ⇒ Object
-
#initialize(params = {}) {|_self| ... } ⇒ Column
constructor
A new instance of Column.
- #opts ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) {|_self| ... } ⇒ Column
Returns a new instance of Column.
15 16 17 18 |
# File 'lib/click_house/definition/column.rb', line 15 def initialize(params = {}) params.each { |k, v| public_send("#{k}=", v) } yield(self) if block_given? end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
11 12 13 |
# File 'lib/click_house/definition/column.rb', line 11 def default @default end |
#extensions ⇒ Object
Returns the value of attribute extensions.
10 11 12 |
# File 'lib/click_house/definition/column.rb', line 10 def extensions @extensions end |
#low_cardinality ⇒ Object
Returns the value of attribute low_cardinality.
9 10 11 |
# File 'lib/click_house/definition/column.rb', line 9 def low_cardinality @low_cardinality end |
#materialized ⇒ Object
Returns the value of attribute materialized.
12 13 14 |
# File 'lib/click_house/definition/column.rb', line 12 def materialized @materialized end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/click_house/definition/column.rb', line 6 def name @name end |
#nullable ⇒ Object
Returns the value of attribute nullable.
8 9 10 |
# File 'lib/click_house/definition/column.rb', line 8 def nullable @nullable end |
#ttl ⇒ Object
Returns the value of attribute ttl.
13 14 15 |
# File 'lib/click_house/definition/column.rb', line 13 def ttl @ttl end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/click_house/definition/column.rb', line 7 def type @type end |
Instance Method Details
#extension_type ⇒ Object
42 43 44 45 46 |
# File 'lib/click_house/definition/column.rb', line 42 def extension_type extensions.nil? ? type : format(type, *extensions) rescue TypeError, ArgumentError raise StandardError, "please provide extensions for <#{type}>" end |
#opts ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/click_house/definition/column.rb', line 28 def opts = { DEFAULT: Util::Statement.ensure(default, default), MATERIALIZED: Util::Statement.ensure(materialized, materialized), TTL: Util::Statement.ensure(ttl, ttl) }.compact result = .each_with_object([]) do |(key, value), object| object << "#{key} #{value}" end result.join(' ') end |
#to_s ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/click_house/definition/column.rb', line 20 def to_s type = extension_type type = "Nullable(#{type})" if nullable type = "LowCardinality(#{type})" if low_cardinality "#{name} #{type} #{opts}" end |