Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ PATH
specs:
postgres_to_redshift (0.1.2)
aws-sdk-v1 (~> 1.54)
pg (~> 0.17.0)
pg (~> 0.18.0)

GEM
remote: https://rubygems.org/
specs:
aws-sdk-v1 (1.66.0)
aws-sdk-v1 (1.67.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
nokogiri (~> 1)
diff-lcs (1.2.5)
json (1.8.3)
mini_portile (0.6.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
pg (0.17.1)
json (1.8.6)
mini_portile2 (2.3.0)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
pg (0.18.4)
rake (10.4.2)
rspec (3.2.0)
rspec-core (~> 3.2.0)
Expand All @@ -42,4 +42,4 @@ DEPENDENCIES
rspec

BUNDLED WITH
1.10.5
1.16.1
20 changes: 19 additions & 1 deletion lib/postgres_to_redshift/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class PostgresToRedshift::Column
"bytea" => "CHARACTER VARYING(65535)",
"money" => "DECIMAL(19,2)",
"oid" => "CHARACTER VARYING(65535)",
"time without time zone" => "CHARACTER VARYING(20)",
"bit" => "CHARACTER(1)",
"ARRAY" => "CHARACTER VARYING(65535)",
"USER-DEFINED" => "CHARACTER VARYING(65535)",
}
Expand All @@ -77,8 +79,24 @@ def data_type
attributes["data_type"]
end

def numeric_precision
attributes["numeric_precision"].to_i
end

def numeric_scale
attributes["numeric_scale"].to_i
end

def data_type_for_copy
CAST_TYPES_FOR_COPY[data_type] || data_type
if data_type == 'numeric'
if numeric_precision == 0
"FLOAT"
else
"DECIMAL(#{numeric_precision},#{numeric_scale})"
end
else
CAST_TYPES_FOR_COPY[data_type] || data_type
end
end

private
Expand Down