embulk-output-vertica 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile +4 -1
- data/README.md +13 -5
- data/embulk-output-vertica.gemspec +1 -1
- data/example.yml +6 -0
- data/lib/embulk/output/vertica.rb +19 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 452d0c45a1e7f46e91cce223618aeffc0141c902
|
4
|
+
data.tar.gz: 16e2bc4294f270f3df7c92243ce28b2ac56f2801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2538b4999f2ea7c7c8ab64c5f1aa5fa90f8dbd7bfc258643c59b00713fdd675bc29654b8c37a07d22cc29e7f9f08db03536de6e4236b14426963c0769f834607
|
7
|
+
data.tar.gz: 0b9a30e215cf0836160e252cf2b77d4e4dc5223b8a5ed1c492b2fc0e16d02bcff26696a61b5c8e23e379a822f416828ea3c29d8700dfe5c62b2f6f4f13af5e0a
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
## Overview
|
4
4
|
|
5
5
|
* **Plugin type**: output
|
6
|
-
* **Load all or nothing**: no
|
7
6
|
* **Resume supported**: no
|
8
|
-
* **Cleanup supported**:
|
7
|
+
* **Cleanup supported**: no
|
8
|
+
* **Dynamic table creating**: yes
|
9
9
|
|
10
10
|
## Configuration
|
11
11
|
|
@@ -17,6 +17,8 @@
|
|
17
17
|
- **schema**: schema name (string, default: public)
|
18
18
|
- **table**: table name (string, required)
|
19
19
|
- **copy_mode**: specifies how data is loaded into the database. (`AUTO`, `DIRECT`, or `TRICKLE`. default: AUTO)
|
20
|
+
- **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
|
21
|
+
- **type**: type of a column when this plugin creates new tables (e.g. VARCHAR(255), INTEGER NOT NULL UNIQUE). This used when this plugin creates intermediate tables (insert and truncate_insert modes), and when it creates nonexistent target table automatically. (string, default: depends on input column type. INT (same with BIGINT in vertica) if input column type is long, BOOLEAN if boolean, FLOAT (same with DOUBLE PRECISION in vertica) if double, VARCHAR if string, TIMESTAMP if timestamp)
|
20
22
|
|
21
23
|
## Example
|
22
24
|
|
@@ -30,6 +32,9 @@ out:
|
|
30
32
|
schema: sandbox
|
31
33
|
table: embulk_test
|
32
34
|
copy_mode: DIRECT
|
35
|
+
column_options:
|
36
|
+
id: {type: INT}
|
37
|
+
name: {type: VARCHAR(255)}
|
33
38
|
```
|
34
39
|
|
35
40
|
|
@@ -38,9 +43,8 @@ out:
|
|
38
43
|
Run example:
|
39
44
|
|
40
45
|
```
|
41
|
-
$
|
42
|
-
$ embulk
|
43
|
-
$ embulk run -I lib -l debug example.yml
|
46
|
+
$ bundle install
|
47
|
+
$ bundle exec embulk run -l debug example.yml
|
44
48
|
```
|
45
49
|
|
46
50
|
Release gem:
|
@@ -48,3 +52,7 @@ Release gem:
|
|
48
52
|
```
|
49
53
|
$ bundle exec rake release
|
50
54
|
```
|
55
|
+
|
56
|
+
## ChangeLog
|
57
|
+
|
58
|
+
[CHANGELOG.md](CHANGELOG.md)
|
@@ -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.2"
|
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
@@ -10,14 +10,15 @@ module Embulk
|
|
10
10
|
|
11
11
|
def self.transaction(config, schema, processor_count, &control)
|
12
12
|
task = {
|
13
|
-
'host'
|
14
|
-
'port'
|
15
|
-
'username'
|
16
|
-
'password'
|
17
|
-
'database'
|
18
|
-
'schema'
|
19
|
-
'table'
|
20
|
-
'copy_mode'
|
13
|
+
'host' => config.param('host', :string, :default => 'localhost'),
|
14
|
+
'port' => config.param('port', :integer, :default => 5433),
|
15
|
+
'username' => config.param('username', :string),
|
16
|
+
'password' => config.param('password', :string, :default => ''),
|
17
|
+
'database' => config.param('database', :string, :default => 'vdb'),
|
18
|
+
'schema' => config.param('schema', :string, :default => 'public'),
|
19
|
+
'table' => config.param('table', :string),
|
20
|
+
'copy_mode' => config.param('copy_mode', :string, :default => 'AUTO'),
|
21
|
+
'column_options' => config.param('column_options', :hash, :default => {}),
|
21
22
|
}
|
22
23
|
|
23
24
|
unless %w[AUTO DIRECT TRICKLE].include?(task['copy_mode'].upcase)
|
@@ -28,7 +29,7 @@ module Embulk
|
|
28
29
|
unique_name = "%08x%08x" % [now.tv_sec, now.tv_nsec]
|
29
30
|
task['temp_table'] = "#{task['table']}_LOAD_TEMP_#{unique_name}"
|
30
31
|
|
31
|
-
sql_schema = self.to_vertica_schema
|
32
|
+
sql_schema = self.to_vertica_schema(schema, task['column_options'])
|
32
33
|
|
33
34
|
connect(task) do |jv|
|
34
35
|
# drop table if exists "DEST"
|
@@ -74,18 +75,20 @@ module Embulk
|
|
74
75
|
jv
|
75
76
|
end
|
76
77
|
|
77
|
-
def self.to_vertica_schema(schema)
|
78
|
-
schema.names.zip(schema.types)
|
79
|
-
|
80
|
-
|
78
|
+
def self.to_vertica_schema(schema, column_options)
|
79
|
+
schema.names.zip(schema.types).map do |name, type|
|
80
|
+
sql_type = (column_options[name] and column_options[name]['type']) ?
|
81
|
+
column_options[name]['type'] : to_sql_type(type)
|
82
|
+
"#{name} #{sql_type}"
|
83
|
+
end.join(',')
|
81
84
|
end
|
82
85
|
|
83
86
|
def self.to_sql_type(type)
|
84
87
|
case type
|
85
88
|
when :boolean then 'BOOLEAN'
|
86
|
-
when :long then 'INT'
|
87
|
-
when :double then 'FLOAT'
|
88
|
-
when :string then 'VARCHAR'
|
89
|
+
when :long then 'INT' # BIGINT is a synonym for INT in vertica
|
90
|
+
when :double then 'FLOAT' # DOUBLE PRECISION is a synonym for FLOAT in vertica
|
91
|
+
when :string then 'VARCHAR' # LONG VARCHAR is not recommended
|
89
92
|
when :timestamp then 'TIMESTAMP'
|
90
93
|
else raise NotSupportedType, "embulk-output-vertica cannot take column type #{type}"
|
91
94
|
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.2
|
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-06-
|
12
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,6 +62,7 @@ extensions: []
|
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
64
|
- .gitignore
|
65
|
+
- CHANGELOG.md
|
65
66
|
- Gemfile
|
66
67
|
- LICENSE.txt
|
67
68
|
- README.md
|