redshift-connector 5.6.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 353a12f1ed7ed90351c0ed041e703f12677adc96
4
- data.tar.gz: 82c7026fe179f663b7aa23c6ee77ac9dcac0fea4
3
+ metadata.gz: f31b6eadc1161cb752be8f735f6ab3cdf2e87d32
4
+ data.tar.gz: edb474edc4bd93ee6ab5efc26d9b9770f05bd109
5
5
  SHA512:
6
- metadata.gz: 94a7f7f64546b8d1007f036f904e06778bca6632ae2fe312c11d0a086b4b63085aa8d91464fd7bdcd47f138ae10360e9b8d81e5def7701a031a994128eadb9a1
7
- data.tar.gz: 7c4da6fd4f9e320ec34d6fc4bc5cc0a2b9723322599ee4a94a795e49e3c1622efa5b16ea7d5f93c1f7cf081ef42eac75e0210381b9225f7661a8fa8567b15872
6
+ metadata.gz: 6d8c0229f3bc0a7beae47859ac7aee5b0df82d82e838ad33803ab9d9e2321e660cd6befd74fee7e800f9394efff425856f20bc0fb77c69dbac407315a65d8333
7
+ data.tar.gz: c7514f15467cf56f6c3b60c0670a4f338645d0b05b96e418500aa9172b696a3f22c3277d498a4e309a779c2ab3202cd4f5a8dd2ad9fcda3e1527390a6a36b74b
@@ -40,30 +40,12 @@ module RedshiftConnector
40
40
  condition: condition,
41
41
  logger: logger
42
42
  )
43
- if delete_cond and upsert_columns
44
- raise ArgumentError, "delete_cond and upsert_columns are exclusive"
45
- end
46
- dao = dest_table.classify.constantize
47
- importer =
48
- if delete_cond
49
- Importer::InsertDelta.new(
50
- dao: dao,
51
- bundle: bundle,
52
- columns: columns,
53
- delete_cond: delete_cond,
54
- logger: logger
55
- )
56
- elsif upsert_columns
57
- Importer::Upsert.new(
58
- dao: dao,
59
- bundle: bundle,
60
- columns: columns,
61
- upsert_columns: upsert_columns,
62
- logger: logger
63
- )
64
- else
65
- raise ArgumentError, "either of delete_cond or upsert_columns is required for transport_delta"
66
- end
43
+ importer = Importer.transport_delta_from_bundle(
44
+ bundle: bundle,
45
+ table: dest_table, columns: columns,
46
+ delete_cond: delete_cond, upsert_columns: upsert_columns,
47
+ logger: logger, quiet: quiet
48
+ )
67
49
  new(exporter: exporter, importer: importer, logger: logger)
68
50
  end
69
51
 
@@ -97,11 +79,11 @@ module RedshiftConnector
97
79
  columns: columns,
98
80
  logger: logger
99
81
  )
100
- importer = Importer.get_rebuild_class(strategy).new(
101
- dao: table.classify.constantize,
82
+ importer = Importer.transport_all_from_bundle(
83
+ strategy: strategy,
102
84
  bundle: bundle,
103
- columns: columns,
104
- logger: logger
85
+ table: table, columns: columns,
86
+ logger: logger, quiet: quiet
105
87
  )
106
88
  new(exporter: exporter, importer: importer, logger: logger)
107
89
  end
@@ -28,6 +28,20 @@ module RedshiftConnector
28
28
  filter: filter,
29
29
  logger: logger
30
30
  )
31
+ transport_delta_from_bundle(
32
+ bundle: bundle,
33
+ table: table, columns: columns,
34
+ delete_cond: delete_cond, upsert_columns: upsert_columns,
35
+ logger: logger, quiet: quiet
36
+ )
37
+ end
38
+
39
+ def Importer.transport_delta_from_bundle(
40
+ bundle:,
41
+ table:, columns:,
42
+ delete_cond: nil, upsert_columns: nil,
43
+ logger: RedshiftConnector.logger, quiet: false
44
+ )
31
45
  if delete_cond and upsert_columns
32
46
  raise ArgumentError, "delete_cond and upsert_columns are exclusive"
33
47
  end
@@ -68,6 +82,20 @@ module RedshiftConnector
68
82
  filter: filter,
69
83
  logger: logger
70
84
  )
85
+ transport_all_from_bundle(
86
+ strategy: strategy,
87
+ bundle: bundle,
88
+ table: table, columns: columns,
89
+ logger: logger, quiet: quiet
90
+ )
91
+ end
92
+
93
+ def Importer.transport_all_from_bundle(
94
+ strategy: 'rename',
95
+ bundle:,
96
+ table:, columns:,
97
+ logger: RedshiftConnector.logger, quiet: false
98
+ )
71
99
  importer = get_rebuild_class(strategy).new(
72
100
  dao: table.classify.constantize,
73
101
  bundle: bundle,
@@ -37,37 +37,6 @@ module RedshiftConnector
37
37
  @bucket.credential_string
38
38
  end
39
39
 
40
- REPORT_SIZE = 10_0000
41
-
42
- def each_batch(report: true)
43
- @logger.info "reader: #{@reader_class}"
44
- n = 0
45
- reported = 0
46
- do_each_batch(@batch_size) do |rows|
47
- yield rows
48
- n += rows.size
49
- if n / REPORT_SIZE > reported
50
- @logger.info "#{n} rows processed" if report
51
- reported = n / REPORT_SIZE
52
- end
53
- end
54
- @logger.info "total #{n} rows processed" if report
55
- end
56
-
57
- def do_each_batch(batch_size)
58
- filter = @filter
59
- buf = []
60
- each_row do |row|
61
- buf.push filter.(*row)
62
- if buf.size == batch_size
63
- yield buf
64
- buf = []
65
- end
66
- end
67
- yield buf unless buf.empty?
68
- end
69
- private :do_each_batch
70
-
71
40
  def data_files
72
41
  @bucket.objects(prefix: @prefix)
73
42
  .map {|obj| S3DataFile.new(obj, reader_class: @reader_class) }
@@ -1,3 +1,3 @@
1
1
  module RedshiftConnector
2
- VERSION = '5.6.0'
2
+ VERSION = '6.0.0'
3
3
  end
data/test/config.rb CHANGED
@@ -1,13 +1,18 @@
1
- $TEST_SCHEMA = 'aamine'
2
-
3
1
  module RedshiftConnector
2
+ # For test only
3
+ $TEST_SCHEMA = 'hidekazukobayashi'
4
+
4
5
  Exporter.default_data_source = Redshift
5
6
 
6
7
  S3Bucket.add(
7
- 'redshift-copy-buffer',
8
- bucket: 'redshift-copy-buffer',
9
- prefix: 'development',
10
- iam_role: 'arn:aws:iam::789035092620:role/RedshiftDevelopers',
8
+ 'test',
9
+ bucket: 'misc-internal.ap-northeast-1',
10
+ prefix: 'development/hidekazu-kobayashi',
11
+ # When using IAM role
12
+ #iam_role: 'arn:aws:iam::NNNNNNNNNNNN:role/RRRRRRRRR',
13
+ # When using explicit access key
14
+ access_key_id: 'AKIAJJGEKUU2MXO3X4NA',
15
+ secret_access_key: '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',
11
16
  default: true
12
17
  )
13
18
  end
data/test/database.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  mysql:
2
2
  adapter: mysql2
3
3
  host: localhost
4
- username: minero-aoki
4
+ username: test
5
5
  database: test
6
6
  encoding: utf8
7
7
 
@@ -10,6 +10,6 @@ redshift:
10
10
  host: dwh.ckpd.co
11
11
  port: 5439
12
12
  database: production
13
- username: aamine
14
- password: "3edCVfr$"
13
+ username: hidekazukobayashi
14
+ password: '?N6s3oH#jc9k3d+P'
15
15
  encoding: utf8
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redshift-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: redshift-connector-data_file
14
+ name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activerecord
28
+ name: activerecord-redshift
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,33 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activerecord-redshift
42
+ name: redshift-connector-data_file
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.1.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
- version: '0'
54
+ version: 1.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pg
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.18.0
61
+ version: '0.18'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.18.0
68
+ version: '0.18'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activerecord-import
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -163,7 +163,6 @@ files:
163
163
  - test/config.rb.example
164
164
  - test/database.yml
165
165
  - test/database.yml.example
166
- - test/foreach.rb
167
166
  - test/helper.rb
168
167
  - test/item_pvs.ct.mysql
169
168
  - test/item_pvs.ct.redshift
@@ -191,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
190
  version: '0'
192
191
  requirements: []
193
192
  rubyforge_project:
194
- rubygems_version: 2.6.8
193
+ rubygems_version: 2.6.11
195
194
  signing_key:
196
195
  specification_version: 4
197
196
  summary: Redshift bulk data connector
data/test/foreach.rb DELETED
@@ -1,5 +0,0 @@
1
- require_relative 'helper'
2
-
3
- RedshiftConnector.foreach(schema: 'tabemiru', table: 'items', query: 'select id from tabemiru.items where id < 50 order by 1', enable_sort: true) do |row|
4
- p row
5
- end