redshift-connector 7.0.2 → 7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +20 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/RELEASE.md +76 -0
- data/Rakefile +3 -0
- data/lib/redshift_connector/version.rb +1 -1
- data/redshift-connector.gemspec +26 -0
- metadata +9 -43
- data/test/all.rb +0 -3
- data/test/config.rb +0 -13
- data/test/config.rb.example +0 -18
- data/test/database.yml +0 -15
- data/test/database.yml.example +0 -15
- data/test/foreach.rb +0 -5
- data/test/helper.rb +0 -25
- data/test/item_pvs.ct.mysql +0 -11
- data/test/item_pvs.ct.redshift +0 -9
- data/test/reader/test_redshift_csv.rb +0 -30
- data/test/test_connector.rb +0 -148
- data/test/test_s3_import.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6d05034adedce4cea33f24328428eb4823e89224eba62cd3548bf41e329cfe5d
|
4
|
+
data.tar.gz: 85b98e33059fcac9e50e505f9eea6cfc53665cf31b66a1de1fc676199150687d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ab6e0528d17951481902ed37679f110bed1718848a17cb962598524e5439e3784dc46b9293222fdf93e0c74ab820d58243e92fc3268172e91019140e99d92dc
|
7
|
+
data.tar.gz: 9800067fa5f06ea4268702519650b1155cdb71c212852402e7cf539f9e25a9408a2987f2e77b97ac6551dd8f5d7511e12fca10d9ebabfcaf07653f5f1feac464
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Packaging
|
2
|
+
*.gem
|
3
|
+
/spec/reports/
|
4
|
+
/spec/examples.txt
|
5
|
+
|
6
|
+
# Documents
|
7
|
+
/.yardoc/
|
8
|
+
/_yardoc/
|
9
|
+
/doc/
|
10
|
+
/rdoc/
|
11
|
+
|
12
|
+
# Bundler
|
13
|
+
/.bundle/
|
14
|
+
/vendor/bundle
|
15
|
+
/lib/bundler/man/
|
16
|
+
Gemfile.lock
|
17
|
+
|
18
|
+
# Gem Specific
|
19
|
+
test/database.yml
|
20
|
+
test/config.rb
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016,2017 Minero Aoki
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/RELEASE.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Release Note
|
2
|
+
|
3
|
+
## version 7.2.1
|
4
|
+
|
5
|
+
- no change.
|
6
|
+
|
7
|
+
## version 7.2.0
|
8
|
+
|
9
|
+
- Removes aws-sdk dependency
|
10
|
+
|
11
|
+
## version 7.0.2
|
12
|
+
|
13
|
+
- [fix] RedshiftConnector.foreach did not work
|
14
|
+
|
15
|
+
## version 7.0.1
|
16
|
+
|
17
|
+
- [fix] RedshiftConnector.transport_delta_from_s3, .transport_all_from_s3 were wrongly dropped, restore them.
|
18
|
+
|
19
|
+
## version 7.0.0
|
20
|
+
|
21
|
+
- [INCOMPATIBLE] Library hierarchy changed: redshift-connector/* -> redshift_connector/*. redshift-connector.rb still exists as an entry point for bundler.
|
22
|
+
- [new] Exporter becomes pluggable. You can implement your own exporter data source instead of ActiveRecord.
|
23
|
+
|
24
|
+
## version 6.0.0
|
25
|
+
|
26
|
+
- version number change only.
|
27
|
+
|
28
|
+
## version 5.6.0
|
29
|
+
|
30
|
+
- Unifies version 4.x (supports Rails 4) and 5.x (supports Rails 5).
|
31
|
+
|
32
|
+
## version 4.5.0 / 5.5.0
|
33
|
+
|
34
|
+
- [new] Separates S3 access layer to another gem: redshift-connector-data_file
|
35
|
+
|
36
|
+
## version 4.4.1 / 5.4.1
|
37
|
+
|
38
|
+
- [new] New option enable_sort for Connector.foreach, to enforce global sorting.
|
39
|
+
|
40
|
+
## version 4.4.0 / 5.4.0
|
41
|
+
|
42
|
+
- [CHANGE] Drops export-only-once feature (and FORCE environment switch), it is not so useful.
|
43
|
+
Exporter now always exports data.
|
44
|
+
|
45
|
+
## version 4.3.2 / 5.3.2
|
46
|
+
|
47
|
+
- [new] Allows reading from S3 signed URL (for separated export/import processes)
|
48
|
+
|
49
|
+
## version 4.3.1 / 5.3.1
|
50
|
+
|
51
|
+
- First release for Rails 5 series.
|
52
|
+
- [fix] Add option for AWS multi-regions support
|
53
|
+
|
54
|
+
## version 4.3.0
|
55
|
+
|
56
|
+
- [new] New method RedshiftConnector.foreach to read rows with UNLOAD
|
57
|
+
|
58
|
+
## version 4.2.0
|
59
|
+
|
60
|
+
- [new] New methods RedshiftConnector.transport_delta_from_s3, .transport_all_from_s3 to read from S3
|
61
|
+
|
62
|
+
## version 4.1.0
|
63
|
+
|
64
|
+
- [new] Introduces rebuild operator. New facade method Connector.transport_all.
|
65
|
+
|
66
|
+
## version 4.0.2
|
67
|
+
|
68
|
+
- [fix] Correctly parses UNLOAD-generated CSV (dangerous characeters are escaped by backslash).
|
69
|
+
|
70
|
+
## version 4.0.1
|
71
|
+
|
72
|
+
- [new] Allow configure the default logger by RedshiftConnector.logger=.
|
73
|
+
|
74
|
+
## version 4.0.0
|
75
|
+
|
76
|
+
First release for Rails 4 series.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'lib/redshift_connector/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.name = 'redshift-connector'
|
6
|
+
s.version = RedshiftConnector::VERSION
|
7
|
+
s.summary = 'Redshift bulk data connector'
|
8
|
+
s.description = 'redshift-connector is a bulk data connector for Rails (ActiveRecord).'
|
9
|
+
s.license = 'MIT'
|
10
|
+
|
11
|
+
s.author = ['Minero Aoki']
|
12
|
+
s.email = 'aamine@loveruby.net'
|
13
|
+
s.homepage = 'https://github.com/bricolages/redshift-connector'
|
14
|
+
|
15
|
+
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
s.require_path = 'lib'
|
17
|
+
|
18
|
+
s.required_ruby_version = '>= 2.1.0'
|
19
|
+
s.add_dependency 'redshift-connector-data_file', '>= 7.0.0'
|
20
|
+
s.add_dependency 'activerecord'
|
21
|
+
s.add_dependency 'activerecord-redshift'
|
22
|
+
s.add_dependency 'pg', '~> 0.18.0'
|
23
|
+
s.add_dependency 'activerecord-import'
|
24
|
+
s.add_development_dependency 'test-unit'
|
25
|
+
s.add_development_dependency 'rake'
|
26
|
+
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: 7.
|
4
|
+
version: 7.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redshift-connector-data_file
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: aws-sdk
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '2.0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '2.0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: test-unit
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,20 +94,6 @@ dependencies:
|
|
108
94
|
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
98
|
name: rake
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,7 +114,12 @@ executables: []
|
|
142
114
|
extensions: []
|
143
115
|
extra_rdoc_files: []
|
144
116
|
files:
|
117
|
+
- ".gitignore"
|
118
|
+
- Gemfile
|
119
|
+
- LICENSE
|
145
120
|
- README.md
|
121
|
+
- RELEASE.md
|
122
|
+
- Rakefile
|
146
123
|
- lib/redshift-connector.rb
|
147
124
|
- lib/redshift_connector.rb
|
148
125
|
- lib/redshift_connector/active_record_data_source.rb
|
@@ -161,18 +138,7 @@ files:
|
|
161
138
|
- lib/redshift_connector/importer/upsert.rb
|
162
139
|
- lib/redshift_connector/query.rb
|
163
140
|
- lib/redshift_connector/version.rb
|
164
|
-
-
|
165
|
-
- test/config.rb
|
166
|
-
- test/config.rb.example
|
167
|
-
- test/database.yml
|
168
|
-
- test/database.yml.example
|
169
|
-
- test/foreach.rb
|
170
|
-
- test/helper.rb
|
171
|
-
- test/item_pvs.ct.mysql
|
172
|
-
- test/item_pvs.ct.redshift
|
173
|
-
- test/reader/test_redshift_csv.rb
|
174
|
-
- test/test_connector.rb
|
175
|
-
- test/test_s3_import.rb
|
141
|
+
- redshift-connector.gemspec
|
176
142
|
homepage: https://github.com/bricolages/redshift-connector
|
177
143
|
licenses:
|
178
144
|
- MIT
|
@@ -193,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
159
|
version: '0'
|
194
160
|
requirements: []
|
195
161
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.6
|
162
|
+
rubygems_version: 2.7.6
|
197
163
|
signing_key:
|
198
164
|
specification_version: 4
|
199
165
|
summary: Redshift bulk data connector
|
data/test/all.rb
DELETED
data/test/config.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
$TEST_SCHEMA = 'aamine'
|
2
|
-
|
3
|
-
module RedshiftConnector
|
4
|
-
Exporter.default_data_source = RedshiftConnector::ActiveRecordDataSource.new(Redshift)
|
5
|
-
|
6
|
-
S3Bucket.add(
|
7
|
-
'redshift-copy-buffer',
|
8
|
-
bucket: 'redshift-copy-buffer',
|
9
|
-
prefix: 'development',
|
10
|
-
iam_role: 'arn:aws:iam::789035092620:role/RedshiftDevelopers',
|
11
|
-
default: true
|
12
|
-
)
|
13
|
-
end
|
data/test/config.rb.example
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module RedshiftConnector
|
2
|
-
# For test only
|
3
|
-
$TEST_SCHEMA = 'test'
|
4
|
-
|
5
|
-
Exporter.default_data_source = Redshift
|
6
|
-
|
7
|
-
S3Bucket.add(
|
8
|
-
'ENTRY_NAME',
|
9
|
-
bucket: 'YOUR_BUCKET_NAME',
|
10
|
-
prefix: 'development',
|
11
|
-
# When using IAM role
|
12
|
-
iam_role: 'arn:aws:iam::NNNNNNNNNNNN:role/RRRRRRRRR',
|
13
|
-
# When using explicit access key
|
14
|
-
#access_key_id: 'AAAAAAAAAA',
|
15
|
-
#secret_access_key: 'SSSSSSSSSS',
|
16
|
-
default: true
|
17
|
-
)
|
18
|
-
end
|
data/test/database.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
mysql:
|
2
|
-
adapter: mysql2
|
3
|
-
host: localhost
|
4
|
-
username: minero-aoki
|
5
|
-
database: test
|
6
|
-
encoding: utf8
|
7
|
-
|
8
|
-
redshift:
|
9
|
-
adapter: redshift
|
10
|
-
host: dwh.ckpd.co
|
11
|
-
port: 5439
|
12
|
-
database: production
|
13
|
-
username: aamine
|
14
|
-
password: "3edCVfr$"
|
15
|
-
encoding: utf8
|
data/test/database.yml.example
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
mysql:
|
2
|
-
adapter: mysql2
|
3
|
-
host: localhost
|
4
|
-
username: USER_NAME
|
5
|
-
database: test
|
6
|
-
encoding: utf8
|
7
|
-
|
8
|
-
redshift:
|
9
|
-
adapter: redshift
|
10
|
-
host: HOST_NAME
|
11
|
-
port: 5439
|
12
|
-
database: DATABASE_NAME
|
13
|
-
username: USER_NAME
|
14
|
-
password: PASSWORD
|
15
|
-
encoding: utf8
|
data/test/foreach.rb
DELETED
data/test/helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
require 'yaml'
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
YAML.load_file("#{__dir__}/database.yml").each do |name, ent|
|
6
|
-
ActiveRecord::Base.configurations[name] = ent
|
7
|
-
end
|
8
|
-
|
9
|
-
class BaseConn < ActiveRecord::Base
|
10
|
-
establish_connection :mysql
|
11
|
-
self.abstract_class = true
|
12
|
-
end
|
13
|
-
class ItemPv < BaseConn
|
14
|
-
connection
|
15
|
-
end
|
16
|
-
class Redshift < ActiveRecord::Base
|
17
|
-
establish_connection :redshift
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'redshift-connector'
|
21
|
-
# This IS REQUIRED to ensure to load mysql2 driver, at least outside of Rails.
|
22
|
-
ActiveRecord::Import.require_adapter 'mysql2'
|
23
|
-
require_relative 'config'
|
24
|
-
|
25
|
-
RedshiftConnector.logger = Logger.new($stderr)
|
data/test/item_pvs.ct.mysql
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
create table item_pvs
|
2
|
-
( id bigint(20) primary key
|
3
|
-
, data_date date not null
|
4
|
-
, item_id int(11) not null
|
5
|
-
, pv bigint(20) not null default 0
|
6
|
-
, uu bigint(20) not null default 0
|
7
|
-
)
|
8
|
-
;
|
9
|
-
|
10
|
-
create unique index item_pvs_idx on item_pvs (id, data_date, item_id) using btree
|
11
|
-
;
|
data/test/item_pvs.ct.redshift
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'redshift-connector/data_file'
|
3
|
-
|
4
|
-
module RedshiftConnector
|
5
|
-
module Reader
|
6
|
-
class TestRedshiftCSV < Test::Unit::TestCase
|
7
|
-
def parse_row(line)
|
8
|
-
r = RedshiftCSV.new(nil)
|
9
|
-
r.parse_row(line, 1)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_parse_row
|
13
|
-
assert_equal ['xxx', 'yyyy', 'zzz'],
|
14
|
-
parse_row(%Q("xxx","yyyy","zzz"\n))
|
15
|
-
|
16
|
-
assert_equal ['xxx', 'yyyy', 'zzz'],
|
17
|
-
parse_row(%Q( "xxx" , "yyyy","zzz"\t\n))
|
18
|
-
|
19
|
-
assert_equal ['x,x', "y\r\ny", 'z"z', 'a\\a'],
|
20
|
-
parse_row(%Q("x\\,x","y\\r\\ny","z\\"z","a\\\\a"\n))
|
21
|
-
|
22
|
-
assert_equal ['981179', '2017-01-07', '6', 'show', '99', '3'],
|
23
|
-
parse_row(%Q("981179","2017-01-07","6","show","99","3"\r\n))
|
24
|
-
|
25
|
-
assert_equal ['981179', '2017-01-07', '6', '852', 'show', '{"page"=>"4"}', '1', '1'],
|
26
|
-
parse_row(%Q("981179","2017-01-07","6","852","show","{\\"page\\"=>\\"4\\"}","1","1"\n))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/test/test_connector.rb
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TestConnector < Test::Unit::TestCase
|
5
|
-
def test_connector_upsert
|
6
|
-
data_date = '2016-11-03'
|
7
|
-
job = RedshiftConnector.transport_delta(
|
8
|
-
schema: $TEST_SCHEMA,
|
9
|
-
table: 'item_pvs',
|
10
|
-
|
11
|
-
txn_id: data_date,
|
12
|
-
condition: %Q(data_date = date '#{data_date}'),
|
13
|
-
|
14
|
-
columns: %w[id data_date item_id pv uu],
|
15
|
-
upsert_columns: %w[pv uu],
|
16
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
17
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
18
|
-
}
|
19
|
-
)
|
20
|
-
job.execute
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_connector_delete_insert
|
24
|
-
data_date = '2016-11-03'
|
25
|
-
job = RedshiftConnector.transport_delta(
|
26
|
-
schema: $TEST_SCHEMA,
|
27
|
-
table: 'item_pvs',
|
28
|
-
|
29
|
-
txn_id: data_date,
|
30
|
-
condition: %Q(data_date = date '#{data_date}'),
|
31
|
-
delete_cond: %Q(data_date = date '#{data_date}'),
|
32
|
-
|
33
|
-
columns: %w[id data_date item_id pv uu],
|
34
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
35
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
36
|
-
}
|
37
|
-
)
|
38
|
-
job.execute
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_dup_options
|
42
|
-
data_date = '2016-11-03'
|
43
|
-
assert_raise(ArgumentError) {
|
44
|
-
RedshiftConnector.transport_delta(
|
45
|
-
schema: $TEST_SCHEMA,
|
46
|
-
table: 'item_pvs',
|
47
|
-
|
48
|
-
txn_id: data_date,
|
49
|
-
condition: %Q(data_date = date '#{data_date}'),
|
50
|
-
delete_cond: %Q(data_date = date '#{data_date}'),
|
51
|
-
|
52
|
-
# Conflicts with delete_cond option
|
53
|
-
upsert_columns: %w[pv uu],
|
54
|
-
|
55
|
-
columns: %w[id data_date item_id pv uu],
|
56
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
57
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
58
|
-
}
|
59
|
-
)
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_no_required_option
|
64
|
-
data_date = '2016-11-03'
|
65
|
-
assert_raise(ArgumentError) {
|
66
|
-
RedshiftConnector.transport_delta(
|
67
|
-
schema: $TEST_SCHEMA,
|
68
|
-
table: 'item_pvs',
|
69
|
-
|
70
|
-
txn_id: data_date,
|
71
|
-
condition: %Q(data_date = date '#{data_date}'),
|
72
|
-
|
73
|
-
columns: %w[id data_date item_id pv uu],
|
74
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
75
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
76
|
-
}
|
77
|
-
)
|
78
|
-
}
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_connector_rebuild_truncate
|
82
|
-
data_date = '2016-11-03'
|
83
|
-
job = RedshiftConnector.transport_all(
|
84
|
-
strategy: 'truncate',
|
85
|
-
schema: $TEST_SCHEMA,
|
86
|
-
table: 'item_pvs',
|
87
|
-
txn_id: data_date,
|
88
|
-
columns: %w[id data_date item_id pv uu],
|
89
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
90
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
91
|
-
}
|
92
|
-
)
|
93
|
-
job.execute
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_connector_rebuild_rename
|
97
|
-
data_date = '2016-11-03'
|
98
|
-
job = RedshiftConnector.transport_all(
|
99
|
-
strategy: 'rename',
|
100
|
-
schema: $TEST_SCHEMA,
|
101
|
-
table: 'item_pvs',
|
102
|
-
txn_id: data_date,
|
103
|
-
columns: %w[id data_date item_id pv uu],
|
104
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
105
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
106
|
-
}
|
107
|
-
)
|
108
|
-
job.execute
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_connector_src_dest_table
|
112
|
-
data_date = '2016-11-03'
|
113
|
-
job = RedshiftConnector.transport_delta(
|
114
|
-
schema: $TEST_SCHEMA,
|
115
|
-
src_table: 'item_pvs',
|
116
|
-
dest_table: 'item_pvs',
|
117
|
-
|
118
|
-
txn_id: data_date,
|
119
|
-
condition: %Q(data_date = date '#{data_date}'),
|
120
|
-
|
121
|
-
columns: %w[id data_date item_id pv uu],
|
122
|
-
upsert_columns: %w[pv uu],
|
123
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
124
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
125
|
-
}
|
126
|
-
)
|
127
|
-
job.execute
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_connector_missing_src_dest
|
131
|
-
data_date = '2016-11-03'
|
132
|
-
assert_raise(ArgumentError) {
|
133
|
-
RedshiftConnector.transport_delta(
|
134
|
-
schema: $TEST_SCHEMA,
|
135
|
-
src_table: 'item_pvs',
|
136
|
-
|
137
|
-
txn_id: data_date,
|
138
|
-
condition: %Q(data_date = date '#{data_date}'),
|
139
|
-
|
140
|
-
columns: %w[id data_date item_id pv uu],
|
141
|
-
upsert_columns: %w[pv uu],
|
142
|
-
filter: -> (id, data_date, item_id, pv, uu) {
|
143
|
-
[id.to_i, data_date, item_id.to_i, pv.to_i, uu.to_i]
|
144
|
-
}
|
145
|
-
)
|
146
|
-
}
|
147
|
-
end
|
148
|
-
end
|
data/test/test_s3_import.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'redshift-connector'
|
4
|
-
|
5
|
-
class TestS3Import < Test::Unit::TestCase
|
6
|
-
def test_import_delta_tsv
|
7
|
-
data_date = '2016-11-03'
|
8
|
-
job = RedshiftConnector.transport_delta_from_s3(
|
9
|
-
prefix: "#{$TEST_SCHEMA}_export/item_pvs_tsv/#{data_date}/item_pvs.tsv.",
|
10
|
-
format: :tsv,
|
11
|
-
|
12
|
-
table: 'item_pvs',
|
13
|
-
columns: %w[id data_date item_id pv uu],
|
14
|
-
upsert_columns: %w[pv uu]
|
15
|
-
)
|
16
|
-
job.execute
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_import_all
|
20
|
-
data_date = '2016-11-03'
|
21
|
-
job = RedshiftConnector.transport_all_from_s3(
|
22
|
-
strategy: 'truncate',
|
23
|
-
|
24
|
-
prefix: "#{$TEST_SCHEMA}_export/item_pvs_tsv/#{data_date}/item_pvs.tsv.",
|
25
|
-
format: :tsv,
|
26
|
-
|
27
|
-
table: 'item_pvs',
|
28
|
-
columns: %w[id data_date item_id pv uu]
|
29
|
-
)
|
30
|
-
job.execute
|
31
|
-
end
|
32
|
-
end
|