redshift_connector 8.1.0 → 8.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RELEASE.md +5 -0
- data/lib/redshift_connector/active_record_exporter.rb +2 -1
- data/lib/redshift_connector/connector.rb +12 -2
- data/lib/redshift_connector/exporter_builder.rb +4 -4
- data/lib/redshift_connector/redshift_data_type.rb +12 -1
- data/lib/redshift_connector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf802a784e9ad99f3d43a7dcae9497c610ae46e4fcf5745ab7843ae8c50ce0eb
|
4
|
+
data.tar.gz: 710ef721c8e4a35384cfb71789413d70ec6dbb205c0395bedefdddc27b9a6f7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64bf13d4fdcc2a43d8ec1310599491a802d88584732a453cdb53f95e048cc5fb3617789b75c3bb78004e76ee2ddbc87fcf7d5d579bccbe76242a7e423a06e0e7
|
7
|
+
data.tar.gz: 404aa0311e7bf20028bf1bc53f2194ef8cd320e76a360c3542be39299a0f48d7df1f42a2d3e2dab67b914cc640127bac42f39bf2a8790d3d177e7b2bed0d19c6
|
data/RELEASE.md
CHANGED
@@ -4,7 +4,8 @@ require 'redshift_connector/logger'
|
|
4
4
|
|
5
5
|
module RedshiftConnector
|
6
6
|
class ActiveRecordExporter
|
7
|
-
def initialize(ds:, query:, bundle_params:, enable_sort: false, logger: RedshiftConnector.logger)
|
7
|
+
def initialize(ds:, query:, bundle_params:, enable_sort: false, enable_cast: false, logger: RedshiftConnector.logger)
|
8
|
+
raise ArgumentError, "ActiveRecordExporter does not support type cast" if enable_cast
|
8
9
|
@ds = ds
|
9
10
|
@query = query
|
10
11
|
@bundle_params = bundle_params
|
@@ -49,13 +49,17 @@ module RedshiftConnector
|
|
49
49
|
upsert_columns: nil,
|
50
50
|
bucket: nil,
|
51
51
|
txn_id: nil,
|
52
|
-
filter
|
52
|
+
filter: nil,
|
53
|
+
enable_cast: false,
|
53
54
|
logger: RedshiftConnector.logger,
|
54
55
|
quiet: false
|
55
56
|
)
|
56
57
|
unless src_table and dest_table
|
57
58
|
raise ArgumentError, "missing :table, :src_table or :dest_table"
|
58
59
|
end
|
60
|
+
raise ArgumentError, "filter and enable_cast are exclusive" if filter and enable_cast
|
61
|
+
raise ArgumentError, "either filter or enable_cast is required" unless filter or enable_cast
|
62
|
+
|
59
63
|
logger = NullLogger.new if quiet
|
60
64
|
bundle_params = DataFileBundleParams.new(
|
61
65
|
bucket: bucket,
|
@@ -70,6 +74,7 @@ module RedshiftConnector
|
|
70
74
|
table: src_table,
|
71
75
|
columns: columns,
|
72
76
|
condition: condition,
|
77
|
+
enable_cast: enable_cast,
|
73
78
|
logger: logger
|
74
79
|
)
|
75
80
|
importer = Importer.for_delta_upsert(
|
@@ -119,10 +124,14 @@ module RedshiftConnector
|
|
119
124
|
columns:,
|
120
125
|
bucket: nil,
|
121
126
|
txn_id: nil,
|
122
|
-
filter
|
127
|
+
filter: nil,
|
128
|
+
enable_cast: false,
|
123
129
|
logger: RedshiftConnector.logger,
|
124
130
|
quiet: false
|
125
131
|
)
|
132
|
+
raise ArgumentError, "filter and enable_cast are exclusive" if filter and enable_cast
|
133
|
+
raise ArgumentError, "either filter or enable_cast is required" unless filter or enable_cast
|
134
|
+
|
126
135
|
logger = NullLogger.new if quiet
|
127
136
|
bundle_params = DataFileBundleParams.new(
|
128
137
|
bucket: bucket,
|
@@ -136,6 +145,7 @@ module RedshiftConnector
|
|
136
145
|
schema: schema,
|
137
146
|
table: src_table,
|
138
147
|
columns: columns,
|
148
|
+
enable_cast: enable_cast,
|
139
149
|
logger: logger
|
140
150
|
)
|
141
151
|
importer = Importer.for_rebuild(
|
@@ -8,14 +8,14 @@ module RedshiftConnector
|
|
8
8
|
@exporter_class = exporter_class
|
9
9
|
end
|
10
10
|
|
11
|
-
def build_for_table_delta(schema:, table:, condition:, columns:, bundle_params:, logger: RedshiftConnector.logger)
|
11
|
+
def build_for_table_delta(schema:, table:, condition:, columns:, enable_cast:, bundle_params:, logger: RedshiftConnector.logger)
|
12
12
|
query = DeltaQuery.new(schema: schema, table: table, columns: columns, condition: condition)
|
13
|
-
@exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, logger: logger)
|
13
|
+
@exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, enable_cast: enable_cast, logger: logger)
|
14
14
|
end
|
15
15
|
|
16
|
-
def build_for_table(schema:, table:, columns:, bundle_params:, logger: RedshiftConnector.logger)
|
16
|
+
def build_for_table(schema:, table:, columns:, enable_cast:, bundle_params:, logger: RedshiftConnector.logger)
|
17
17
|
query = SelectAllQuery.new(schema: schema, table: table, columns: columns)
|
18
|
-
@exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, logger: logger)
|
18
|
+
@exporter_class.new(ds: @ds, query: query, bundle_params: bundle_params, enable_cast: enable_cast, logger: logger)
|
19
19
|
end
|
20
20
|
|
21
21
|
def build_for_query(
|
@@ -1,6 +1,17 @@
|
|
1
1
|
|
2
2
|
module RedshiftConnector
|
3
3
|
module RedshiftDataType
|
4
|
+
FALSE_VALUES = [
|
5
|
+
false, 0,
|
6
|
+
"0", :"0",
|
7
|
+
"f", :f,
|
8
|
+
"F", :F,
|
9
|
+
"false", :false,
|
10
|
+
"FALSE", :FALSE,
|
11
|
+
"off", :off,
|
12
|
+
"OFF", :OFF,
|
13
|
+
].to_set.freeze
|
14
|
+
|
4
15
|
def self.type_cast(row, manifest_file)
|
5
16
|
row.zip(manifest_file.column_types).map do |value, type|
|
6
17
|
next nil if (value == '' and type != 'character varing') # null becomes '' on unload
|
@@ -17,7 +28,7 @@ module RedshiftConnector
|
|
17
28
|
when 'date'
|
18
29
|
Date.parse(value)
|
19
30
|
when 'boolean'
|
20
|
-
value
|
31
|
+
FALSE_VALUES.include?(value) ? false : true
|
21
32
|
else
|
22
33
|
raise "not support data type: #{type}"
|
23
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redshift_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.1.
|
4
|
+
version: 8.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10
|
11
|
+
date: 2021-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|