redshift_connector 8.0.0 → 8.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RELEASE.md +19 -0
- data/lib/redshift_connector/active_record_exporter.rb +2 -1
- data/lib/redshift_connector/connector.rb +12 -2
- data/lib/redshift_connector/data_file_bundle_reader.rb +10 -1
- data/lib/redshift_connector/exporter_builder.rb +8 -4
- data/lib/redshift_connector/redshift_data_type.rb +38 -0
- data/lib/redshift_connector/version.rb +1 -1
- data/redshift_connector.gemspec +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ceccb9545b9d59e71696a1adc38413e7685f1ea191805200f08d47ae2b301eb
|
4
|
+
data.tar.gz: 8e0c019d98d823b59614f02b14dd6b47e5b9adbe5483923269091f895b818a78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76dda7e7a2fb23794fb056bf0aaa81aff5ecbb3d98bb46b70903de6ceb68d51073597baceeefac88fa9a4ed04df100a4ebec1b5e2cee23eeeed7a485ba7a992b
|
7
|
+
data.tar.gz: ec3ac1e0fb7416cd5c6216ee5b3df9c8c0bb6a4e28383effc99607bbba564f22aee2c7d025fcd7518d69165ec2599fbc2090e8c08c523e983f8f7fe0776838fd
|
data/RELEASE.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Release Note
|
2
2
|
|
3
|
+
## version 8.1.3
|
4
|
+
- [fix] Mishandling time zone for timestamp type.
|
5
|
+
|
6
|
+
## version 8.1.2
|
7
|
+
- [new] Add type cast option instead of filter option for #transport_delta and #transport_all.
|
8
|
+
|
9
|
+
## version 8.1.1
|
10
|
+
- [fix] Boolean type cast was reverse.
|
11
|
+
|
12
|
+
## version 8.1.0
|
13
|
+
|
14
|
+
- [new] Add type cast option for queuery.
|
15
|
+
|
16
|
+
## version 8.0.1
|
17
|
+
|
18
|
+
- [fix] Loosen pg version restriction to allow >0.18 to support Rails 5.
|
19
|
+
Note that Redshift is PostgreSQL 8 compatible and pg >0.18 does not support PostgreSQL 8.
|
20
|
+
Now you can use any version of pg and most version of pg works with Redshift, but you must take a risk.
|
21
|
+
|
3
22
|
## version 8.0.0
|
4
23
|
|
5
24
|
- [INCOMPATIBLE] This library is renamed to "redshift_connector". Just modify your Gemfile from "redshift-connector" to "redshift_connector".
|
@@ -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(
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'redshift_connector/logger'
|
2
|
+
require 'redshift_connector/redshift_data_type'
|
2
3
|
require 'forwardable'
|
3
4
|
|
4
5
|
module RedshiftConnector
|
@@ -22,7 +23,14 @@ module RedshiftConnector
|
|
22
23
|
|
23
24
|
def each_row(&block)
|
24
25
|
each_object do |obj|
|
25
|
-
|
26
|
+
if @bundle.respond_to?(:has_manifest?) && @bundle.has_manifest?
|
27
|
+
obj.each_row do |row|
|
28
|
+
yield RedshiftDataType.type_cast(row, @bundle.manifest_file)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
obj.each_row(&block)
|
32
|
+
end
|
33
|
+
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
@@ -68,5 +76,6 @@ module RedshiftConnector
|
|
68
76
|
yield buf unless buf.empty?
|
69
77
|
end
|
70
78
|
private :do_each_batch
|
79
|
+
|
71
80
|
end
|
72
81
|
end
|
@@ -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(
|
@@ -23,8 +23,10 @@ module RedshiftConnector
|
|
23
23
|
table:,
|
24
24
|
bucket: nil,
|
25
25
|
query:,
|
26
|
+
query_params: [],
|
26
27
|
txn_id: "#{Time.now.strftime('%Y%m%d_%H%M%S')}_#{$$}",
|
27
28
|
enable_sort: false,
|
29
|
+
enable_cast: false,
|
28
30
|
logger: RedshiftConnector.logger,
|
29
31
|
quiet: false
|
30
32
|
)
|
@@ -39,8 +41,10 @@ module RedshiftConnector
|
|
39
41
|
@exporter_class.new(
|
40
42
|
ds: @ds,
|
41
43
|
query: ArbitraryQuery.new(query),
|
44
|
+
query_params: query_params,
|
42
45
|
bundle_params: bundle_params,
|
43
46
|
enable_sort: enable_sort,
|
47
|
+
enable_cast: enable_cast,
|
44
48
|
logger: logger
|
45
49
|
)
|
46
50
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
module RedshiftConnector
|
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
|
+
|
15
|
+
def self.type_cast(row, manifest_file)
|
16
|
+
row.zip(manifest_file.column_types).map do |value, type|
|
17
|
+
next nil if (value == '' and type != 'character varing') # null becomes '' on unload
|
18
|
+
|
19
|
+
case type
|
20
|
+
when 'smallint', 'integer', 'bigint'
|
21
|
+
value.to_i
|
22
|
+
when 'numeric', 'double precision'
|
23
|
+
value.to_f
|
24
|
+
when 'character', 'character varying'
|
25
|
+
value
|
26
|
+
when 'timestamp without time zone', 'timestamp with time zone'
|
27
|
+
value # Ruby does not have a class without timezone
|
28
|
+
when 'date'
|
29
|
+
Date.parse(value)
|
30
|
+
when 'boolean'
|
31
|
+
FALSE_VALUES.include?(value) ? false : true
|
32
|
+
else
|
33
|
+
raise "not support data type: #{type}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/redshift_connector.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.required_ruby_version = '>= 2.1.0'
|
19
19
|
s.add_dependency 'activerecord'
|
20
20
|
s.add_dependency 'activerecord-redshift'
|
21
|
-
s.add_dependency 'pg', '
|
21
|
+
s.add_dependency 'pg', '>= 0.18.0'
|
22
22
|
s.add_dependency 'activerecord-import'
|
23
23
|
s.add_dependency 'redshift_csv_file', '~> 1.0'
|
24
24
|
s.add_dependency 'aws-sdk-s3', '~> 1.0'
|
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.
|
4
|
+
version: 8.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: pg
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.18.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.18.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/redshift_connector/reader/exception.rb
|
160
160
|
- lib/redshift_connector/reader/redshift_csv.rb
|
161
161
|
- lib/redshift_connector/reader/tsv.rb
|
162
|
+
- lib/redshift_connector/redshift_data_type.rb
|
162
163
|
- lib/redshift_connector/s3_bucket.rb
|
163
164
|
- lib/redshift_connector/s3_data_file.rb
|
164
165
|
- lib/redshift_connector/s3_data_file_bundle.rb
|
@@ -168,7 +169,7 @@ homepage: https://github.com/bricolages/redshift_connector
|
|
168
169
|
licenses:
|
169
170
|
- MIT
|
170
171
|
metadata: {}
|
171
|
-
post_install_message:
|
172
|
+
post_install_message:
|
172
173
|
rdoc_options: []
|
173
174
|
require_paths:
|
174
175
|
- lib
|
@@ -183,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
- !ruby/object:Gem::Version
|
184
185
|
version: '0'
|
185
186
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
187
|
-
signing_key:
|
187
|
+
rubygems_version: 3.1.6
|
188
|
+
signing_key:
|
188
189
|
specification_version: 4
|
189
190
|
summary: Redshift bulk data connector
|
190
191
|
test_files: []
|