embulk-output-vertica 0.6.2 → 0.7.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: eb34c1b088bf2c2f7320d0c6bb1e076b84495683
4
- data.tar.gz: 300769b3f384905879b654fce8e783b0b85d2262
3
+ metadata.gz: e728473aef9d73c5ff031ba16f354129fce903ac
4
+ data.tar.gz: 701b369758f736ca57455e4ba15d395ece62669f
5
5
  SHA512:
6
- metadata.gz: e94f3b6f86bb97b2dc01862db20113111cb030605996cc10f02c1dacada7bc227a17be8e9589312cb49a916a60a58a15acb42ad40a93a49fa1d5dff7c99d03ec
7
- data.tar.gz: 98547b91c62437e1a732f72f0dcc35b378ed68d41423c1f6681c3e86acf4cd63be8bd80d24536e35a53de6299c5c2ddc414eba62dfd92f18bde665442a19dc56
6
+ metadata.gz: 5e7ca636569766779460699fbec289c9f6c246c8a35d85ed3764a8f0e7af6c3453c4a32771fcf81313217ab2867d06326026aa86ff61e721f60fc0d224717891
7
+ data.tar.gz: 873396d69807a19426a8ec5d088d86c8a081b3e381e283298d4952615963598fd1d33acd96605f4775d2fa4c028dc586d535838915db6df5493eaabc32c9365f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 0.7.0 (2016/01/29)
2
+
3
+ Breaking Changes:
4
+
5
+ * rename mode `REPLACE` to `DROP_INSERT`
6
+
7
+ Enhancements:
8
+
9
+ * Add mode `REPLACE` which copies rows to an intermediate table first. If all those tasks run correctly, swaps the target table and the intermediate table, and drops the old target table
10
+
1
11
  # 0.6.2 (2016/01/28)
2
12
 
3
13
  Enhancements:
data/README.md CHANGED
@@ -44,11 +44,11 @@
44
44
  ### Modes
45
45
 
46
46
  * **insert**:
47
- * Behavior: This mode copys rows to some intermediate tables first. If all those tasks run correctly, runs INSERT INTO <target_table> SELECT * FROM <intermediate_table>
48
- * Transactional: Yes if `abort_on_error` option is used
47
+ * Behavior: This mode copies rows to some intermediate tables first. If all those tasks run correctly, runs INSERT INTO <target_table> SELECT * FROM <intermediate_table>
49
48
  * **replace**:
50
- * Behavior: Same with insert mode excepting that it drops the target table first.
51
- * Transactional: Yes if `abort_on_error` option is used
49
+ * Behavior: This mode copies rows to an intermediate table first. If all those tasks run correctly, swaps the target table and the intermediate table, and drops the old target table
50
+ * **drop_insert**:
51
+ * Behavior: Same with insert mode excepting that it drops the target table first. This is aimed to use for development.
52
52
 
53
53
  ## Example
54
54
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-output-vertica"
3
- spec.version = "0.6.2"
3
+ spec.version = "0.7.0"
4
4
  spec.authors = ["eiji.sekiya", "Naotoshi Seo"]
5
5
  spec.email = ["eiji.sekiya.0326@gmail.com", "sonots@gmail.com"]
6
6
  spec.summary = "Vertica output plugin for Embulk"
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
14
  spec.require_paths = ["lib"]
15
15
 
16
- spec.add_dependency "jvertica", "~> 0.2"
16
+ spec.add_dependency "jvertica", ">= 0.2.2"
17
17
  spec.add_dependency "tzinfo"
18
18
  spec.add_development_dependency "bundler", "~> 1.7"
19
19
  spec.add_development_dependency "rake", "~> 10.0"
data/example/abort.yml CHANGED
@@ -24,7 +24,7 @@ out:
24
24
  database: vdb
25
25
  schema: sandbox
26
26
  table: embulk_test
27
- mode: replace
27
+ mode: drop_insert
28
28
  copy_mode: DIRECT
29
29
  abort_on_error: true
30
30
  reject_on_materialized_type_error: true
data/example/example.yml CHANGED
@@ -31,7 +31,7 @@ out:
31
31
  database: vdb
32
32
  schema: sandbox
33
33
  table: embulk_test
34
- mode: replace
34
+ mode: drop_insert
35
35
  copy_mode: DIRECT
36
36
  abort_on_error: true
37
37
  reject_on_materialized_type_error: true
@@ -0,0 +1,33 @@
1
+ in:
2
+ type: file
3
+ path_prefix: example/example.csv
4
+ parser:
5
+ type: csv
6
+ charset: UTF-8
7
+ newline: CRLF
8
+ null_string: 'NULL'
9
+ skip_header_lines: 1
10
+ comment_line_marker: '#'
11
+ columns:
12
+ - {name: timestamp_date, type: timestamp, format: "%Y-%m-%d", timezone: "+09:00"}
13
+ - {name: string_date, type: string}
14
+ - {name: foo, type: string}
15
+ - {name: bar, type: string}
16
+ - {name: id, type: long}
17
+ - {name: name, type: string}
18
+ - {name: score, type: double}
19
+ out:
20
+ type: vertica
21
+ host: 127.0.0.1
22
+ user: dbadmin
23
+ password: xxxxxxx
24
+ database: vdb
25
+ schema: sandbox
26
+ table: jvertica_test
27
+ mode: replace
28
+ copy_mode: DIRECT
29
+ abort_on_error: true
30
+ reject_on_materialized_type_error: true
31
+ default_timezone: 'Asia/Tokyo'
32
+ pool: 3
33
+ compress: GZIP
@@ -0,0 +1,34 @@
1
+ in:
2
+ type: file
3
+ path_prefix: example/example.csv
4
+ parser:
5
+ type: csv
6
+ charset: UTF-8
7
+ newline: CRLF
8
+ null_string: 'NULL'
9
+ skip_header_lines: 1
10
+ comment_line_marker: '#'
11
+ columns:
12
+ - {name: timestamp_date, type: timestamp, format: "%Y-%m-%d", timezone: "+09:00"}
13
+ - {name: string_date, type: string}
14
+ - {name: foo, type: string}
15
+ - {name: bar, type: string}
16
+ - {name: id, type: long}
17
+ - {name: name, type: string}
18
+ - {name: score, type: double}
19
+ out:
20
+ type: vertica
21
+ host: 127.0.0.1
22
+ user: dbadmin
23
+ password: xxxxxxx
24
+ database: vdb
25
+ schema: sandbox
26
+ table: jvertica_test
27
+ mode: drop_inesrt
28
+ copy_mode: DIRECT
29
+ abort_on_error: true
30
+ reject_on_materialized_type_error: true
31
+ default_timezone: 'Asia/Tokyo'
32
+ pool: 3
33
+ compress: GZIP
34
+ resource_pool: default
@@ -46,8 +46,8 @@ module Embulk
46
46
  end
47
47
 
48
48
  task['mode'] = task['mode'].upcase
49
- unless %w[INSERT REPLACE].include?(task['mode'])
50
- raise ConfigError.new "`mode` must be one of INSERT, REPLACE"
49
+ unless %w[INSERT REPLACE DROP_INSERT].include?(task['mode'])
50
+ raise ConfigError.new "`mode` must be one of INSERT, REPLACE, DROP_INSERT"
51
51
  end
52
52
 
53
53
  task['copy_mode'] = task['copy_mode'].upcase
@@ -74,7 +74,7 @@ module Embulk
74
74
  sql_schema_table = self.sql_schema_from_embulk_schema(schema, task['column_options'])
75
75
 
76
76
  # create the target table
77
- query(jv, %[DROP TABLE IF EXISTS #{quoted_schema}.#{quoted_table}]) if task['mode'] == 'REPLACE'
77
+ query(jv, %[DROP TABLE IF EXISTS #{quoted_schema}.#{quoted_table}]) if task['mode'] == 'DROP_INSERT'
78
78
  query(jv, %[CREATE TABLE IF NOT EXISTS #{quoted_schema}.#{quoted_table} (#{sql_schema_table})])
79
79
  end
80
80
 
@@ -98,11 +98,20 @@ module Embulk
98
98
  task_reports = thread_pool.commit
99
99
  Embulk.logger.info { "embulk-output-vertica: task_reports: #{task_reports.to_json}" }
100
100
 
101
- # insert select from the temp table
102
101
  connect(task) do |jv|
103
- hint = '/*+ direct */ ' if task['copy_mode'] == 'DIRECT' # I did not prepare a specific option, does anyone want?
104
- query(jv, %[INSERT #{hint}INTO #{quoted_schema}.#{quoted_table} SELECT * FROM #{quoted_schema}.#{quoted_temp_table}])
105
- jv.commit
102
+ if task['mode'] == 'REPLACE'
103
+ # swap table and drop the old table
104
+ quoted_old_table = ::Jvertica.quote_identifier("#{task['table']}_LOAD_OLD_#{unique_name}")
105
+ from = "#{quoted_schema}.#{quoted_table},#{quoted_schema}.#{quoted_temp_table}"
106
+ to = "#{quoted_old_table},#{quoted_table}"
107
+ query(jv, %[ALTER TABLE #{from} RENAME TO #{to}])
108
+ query(jv, %[DROP TABLE #{quoted_schema}.#{quoted_old_table}])
109
+ else
110
+ # insert select from the temp table
111
+ hint = '/*+ direct */ ' if task['copy_mode'] == 'DIRECT' # I did not prepare a specific option, does anyone want?
112
+ query(jv, %[INSERT #{hint}INTO #{quoted_schema}.#{quoted_table} SELECT * FROM #{quoted_schema}.#{quoted_temp_table}])
113
+ jv.commit
114
+ end
106
115
  end
107
116
  ensure
108
117
  connect(task) do |jv|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-vertica
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - eiji.sekiya
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-28 00:00:00.000000000 Z
12
+ date: 2016-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jvertica
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0.2'
20
+ version: 0.2.2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '0.2'
27
+ version: 0.2.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: tzinfo
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +87,8 @@ files:
87
87
  - example/example.jsonl
88
88
  - example/example.yml
89
89
  - example/json_payload.yml
90
+ - example/replace.yml
91
+ - example/resource_pool.yml
90
92
  - lib/embulk/output/vertica.rb
91
93
  - lib/embulk/output/vertica/output_thread.rb
92
94
  - lib/embulk/output/vertica/value_converter_factory.rb