embulk-output-vertica 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +6 -5
- data/embulk-output-vertica.gemspec +1 -1
- data/example.yml +3 -0
- data/lib/embulk/output/vertica.rb +28 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daadcaba0204e6e4c1103f4edd8e5b3c6b70924f
|
4
|
+
data.tar.gz: 339ab9e6350031e1325ac69d2773f45bc6f7e0b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecec7a142322fdff6596c3359fb67949235d8082ae626e491df8ed5cce55961777eb7715cb69a7d12243f3305ec97595a97c3e820188f6198f3a68e43595e01f
|
7
|
+
data.tar.gz: 7d17307369af315a30ab296aad4bb94da6ff08806db4f73fef541c1aa710326a7e251804e730004c854be97a68a194059306867b484f607af7864e02210e9bd5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,13 +19,14 @@
|
|
19
19
|
- **mode**: "insert", or "replace". See bellow. (string, default: insert)
|
20
20
|
- **copy_mode**: specifies how data is loaded into the database. (`AUTO`, `DIRECT`, or `TRICKLE`. default: AUTO) See vertica documents for details.
|
21
21
|
- **abort_on_error**: Stops the COPY command if a row is rejected and rolls back the command. No data is loaded. (bool, default: false)
|
22
|
+
- **reject_on_materialized_type_error**: Use `reject_on_materialized_type_error` option for fjsonparser(). This rejects rows if any of olumn types and value types do not fit. ex) double value into INT column fails. See vertica documents for details. (bool, default: false)
|
22
23
|
- **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
|
23
24
|
- **type**: type of a column when this plugin creates new tables such as `VARCHAR(255)`, `INTEGER NOT NULL UNIQUE`. This is used on creating intermediate tables (insert and truncate_insert modes) and on creating a new target table. (string, default: depends on input column type, see below)
|
24
|
-
- `INT` (same with `BIGINT` in vertica)
|
25
|
-
- `BOOLEAN`
|
26
|
-
- `FLOAT` (same with `DOUBLE PRECISION` in vertica)
|
27
|
-
- `VARCHAR`
|
28
|
-
- `TIMESTAMP`
|
25
|
+
- long: `INT` (same with `BIGINT` in vertica)
|
26
|
+
- boolean: `BOOLEAN`
|
27
|
+
- double: `FLOAT` (same with `DOUBLE PRECISION` in vertica)
|
28
|
+
- string: `VARCHAR`
|
29
|
+
- timestamp: `TIMESTAMP`
|
29
30
|
|
30
31
|
### Modes
|
31
32
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "embulk-output-vertica"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.7"
|
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"
|
data/example.yml
CHANGED
@@ -20,6 +20,7 @@ module Embulk
|
|
20
20
|
'mode' => config.param('mode', :string, :default => 'insert'),
|
21
21
|
'copy_mode' => config.param('copy_mode', :string, :default => 'AUTO'),
|
22
22
|
'abort_on_error' => config.param('abort_on_error', :bool, :default => false),
|
23
|
+
'reject_on_materialized_type_error' => config.param('reject_on_materialized_type_error', :bool, :default => false),
|
23
24
|
'column_options' => config.param('column_options', :hash, :default => {}),
|
24
25
|
}
|
25
26
|
|
@@ -59,7 +60,7 @@ module Embulk
|
|
59
60
|
ensure
|
60
61
|
connect(task) do |jv|
|
61
62
|
query(jv, %[DROP TABLE IF EXISTS #{quoted_schema}.#{quoted_temp_table}])
|
62
|
-
Embulk.logger.debug { query(jv, %[SELECT * FROM #{quoted_schema}.#{quoted_table} LIMIT 10]).map {|row| row.to_h }.join("\n") rescue nil }
|
63
|
+
Embulk.logger.debug { "embulk-output-vertica: #{query(jv, %[SELECT * FROM #{quoted_schema}.#{quoted_table} LIMIT 10]).map {|row| row.to_h }.join("\n") rescue nil}" }
|
63
64
|
end
|
64
65
|
end
|
65
66
|
return {}
|
@@ -75,12 +76,25 @@ module Embulk
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def add(page)
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
json = nil # for log
|
80
|
+
begin
|
81
|
+
copy(@jv, copy_sql) do |stdin|
|
82
|
+
page.each do |record|
|
83
|
+
json = to_json(record)
|
84
|
+
stdin << json << "\n"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
Embulk.logger.debug "embulk-output-vertica: COMMIT!"
|
88
|
+
@jv.commit
|
89
|
+
rescue java.sql.SQLDataException => e
|
90
|
+
@jv.rollback
|
91
|
+
if @task['reject_on_materialized_type_error'] and e.message =~ /Rejected by user-defined parser/
|
92
|
+
Embulk.logger.warn "embulk-output-vertica: ROLLBACK! some of column types and values types do not fit #{json}"
|
93
|
+
else
|
94
|
+
Embulk.logger.warn "embulk-output-vertica: ROLLBACK!"
|
81
95
|
end
|
96
|
+
raise e
|
82
97
|
end
|
83
|
-
@jv.commit
|
84
98
|
end
|
85
99
|
|
86
100
|
def finish
|
@@ -154,7 +168,7 @@ module Embulk
|
|
154
168
|
end
|
155
169
|
|
156
170
|
def copy_sql
|
157
|
-
@copy_sql ||= "COPY #{quoted_schema}.#{quoted_temp_table} FROM STDIN
|
171
|
+
@copy_sql ||= "COPY #{quoted_schema}.#{quoted_temp_table} FROM STDIN#{fjsonparser}#{copy_mode}#{abort_on_error} NO COMMIT"
|
158
172
|
end
|
159
173
|
|
160
174
|
def to_json(record)
|
@@ -174,13 +188,20 @@ module Embulk
|
|
174
188
|
end
|
175
189
|
|
176
190
|
def copy_mode
|
177
|
-
@task['copy_mode']
|
191
|
+
" #{@task['copy_mode']}"
|
178
192
|
end
|
179
193
|
|
180
194
|
def abort_on_error
|
181
195
|
@task['abort_on_error'] ? ' ABORT ON ERROR' : ''
|
182
196
|
end
|
183
197
|
|
198
|
+
def fjsonparser
|
199
|
+
" PARSER fjsonparser(#{reject_on_materialized_type_error})"
|
200
|
+
end
|
201
|
+
|
202
|
+
def reject_on_materialized_type_error
|
203
|
+
@task['reject_on_materialized_type_error'] ? 'reject_on_materialized_type_error=true' : ''
|
204
|
+
end
|
184
205
|
end
|
185
206
|
end
|
186
207
|
end
|
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.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eiji.sekiya
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-07-
|
12
|
+
date: 2015-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|