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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe435fb50a129cc904e31d2e87d9119804acf854
4
- data.tar.gz: 23458272c05c2b660033b4ec893f18913080fb6e
3
+ metadata.gz: 452d0c45a1e7f46e91cce223618aeffc0141c902
4
+ data.tar.gz: 16e2bc4294f270f3df7c92243ce28b2ac56f2801
5
5
  SHA512:
6
- metadata.gz: 92258f1615b0bb2157a67840e782d141c37752ae2dbb6bf8ed272b958375727a740c5ca902162b66c691df42e4356797499430ce02fb3bbe4d1b5ee7e95e56b2
7
- data.tar.gz: 170a6dd3a87987a25d9977fad7674330be58a20bcf89002a0060a16db96c587ce7c978cdb81c3063226c35778bf12ab7fc14834df52d60d926bfaa97175bc529
6
+ metadata.gz: 2538b4999f2ea7c7c8ab64c5f1aa5fa90f8dbd7bfc258643c59b00713fdd675bc29654b8c37a07d22cc29e7f9f08db03536de6e4236b14426963c0769f834607
7
+ data.tar.gz: 0b9a30e215cf0836160e252cf2b77d4e4dc5223b8a5ed1c492b2fc0e16d02bcff26696a61b5c8e23e379a822f416828ea3c29d8700dfe5c62b2f6f4f13af5e0a
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # 0.1.2 (2015/06/26)
2
+
3
+ Enhancements:
4
+
5
+ * Add `column_options` option
6
+
7
+ # 0.1.1 (2015/06/25)
8
+
9
+ Enhancements:
10
+
11
+ * Add `copy_mode` option
12
+ * Use `jvertica` gem instead of `vertica` gem
13
+
14
+ # 0.1.0
15
+
16
+ first version
17
+
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in embulk-plugin-vertica.gemspec
4
3
  gemspec
4
+ gem 'embulk'
5
+ gem 'embulk-input-random'
6
+ gem 'pry'
7
+ gem 'pry-nav'
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**: yes
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
- $ embulk gem install embulk-input-random
42
- $ embulk gem install jvertica
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.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
@@ -13,3 +13,9 @@ out:
13
13
  database: vdb
14
14
  schema: sandbox
15
15
  table: embulk_test
16
+ copy_mode: direct
17
+ column_options:
18
+ id: {type: INT}
19
+ name: {type: VARCHAR}
20
+ score: {type: INT}
21
+
@@ -10,14 +10,15 @@ module Embulk
10
10
 
11
11
  def self.transaction(config, schema, processor_count, &control)
12
12
  task = {
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'),
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 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
- .map { |name, type| "#{name} #{to_sql_type(type)}" }
80
- .join(',')
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.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-25 00:00:00.000000000 Z
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