Class: PostgresToRedshift::Column
- Inherits:
-
Object
- Object
- PostgresToRedshift::Column
- Defined in:
- lib/postgres_to_redshift/column.rb
Overview
table_catalog | postgres_to_redshift table_schema | public table_name | films column_name | description ordinal_position | 2 column_default | is_nullable | YES data_type | character varying character_maximum_length | 255 character_octet_length | 1020 numeric_precision | numeric_precision_radix | numeric_scale | datetime_precision | interval_type | interval_precision | character_set_catalog | character_set_schema | character_set_name | collation_catalog | collation_schema | collation_name | domain_catalog | domain_schema | domain_name | udt_catalog | postgres_to_redshift udt_schema | pg_catalog udt_name | varchar scope_catalog | scope_schema | scope_name | maximum_cardinality | dtd_identifier | 2 is_self_referencing | NO is_identity | NO identity_generation | identity_start | identity_increment | identity_maximum | identity_minimum | identity_cycle | is_generated | NEVER generation_expression | is_updatable | YES
Constant Summary collapse
- CAST_TYPES_FOR_COPY =
{ "text" => "CHARACTER VARYING(65535)", "json" => "CHARACTER VARYING(65535)", "bytea" => "CHARACTER VARYING(65535)", "money" => "DECIMAL(19,2)", "oid" => "CHARACTER VARYING(65535)", }
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
- #data_type ⇒ Object
- #data_type_for_copy ⇒ Object
-
#initialize(attributes:) ⇒ Column
constructor
A new instance of Column.
- #name ⇒ Object
- #name_for_copy ⇒ Object
Constructor Details
#initialize(attributes:) ⇒ Column
Returns a new instance of Column.
57 58 59 |
# File 'lib/postgres_to_redshift/column.rb', line 57 def initialize(attributes: ) self.attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
47 48 49 |
# File 'lib/postgres_to_redshift/column.rb', line 47 def attributes @attributes end |
Instance Method Details
#data_type ⇒ Object
73 74 75 |
# File 'lib/postgres_to_redshift/column.rb', line 73 def data_type attributes["data_type"] end |
#data_type_for_copy ⇒ Object
77 78 79 |
# File 'lib/postgres_to_redshift/column.rb', line 77 def data_type_for_copy CAST_TYPES_FOR_COPY[data_type] || data_type end |
#name ⇒ Object
61 62 63 |
# File 'lib/postgres_to_redshift/column.rb', line 61 def name attributes["column_name"] end |
#name_for_copy ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/postgres_to_redshift/column.rb', line 65 def name_for_copy if needs_type_cast? %Q[CAST("#{name}" AS #{data_type_for_copy}) AS #{name}] else %Q["#{name}"] end end |