15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/queuery_client/redshift_data_type.rb', line 15
def self.type_cast(row, manifest_file)
row.zip(manifest_file.column_types).map do |value, type|
next nil if (value == '' and type != 'character varing')
case type
when 'smallint', 'integer', 'bigint'
value.to_i
when 'numeric', 'double precision'
value.to_f
when 'character', 'character varying'
value
when 'timestamp without time zone', 'timestamp with time zone'
value when 'date'
Date.parse(value)
when 'boolean'
FALSE_VALUES.include?(value) ? false : true
else
raise "not support data type: #{type}"
end
end
end
|