embulk-output-postgresql 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -1
- data/classpath/{embulk-output-jdbc-0.5.1.jar → embulk-output-jdbc-0.6.0.jar} +0 -0
- data/classpath/{embulk-output-postgresql-0.5.1.jar → embulk-output-postgresql-0.6.0.jar} +0 -0
- data/src/main/java/org/embulk/output/PostgreSQLOutputPlugin.java +24 -12
- data/src/main/java/org/embulk/output/postgresql/setter/PostgreSQLColumnSetterFactory.java +30 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e06631517e53bd9848c6e4e1f97761bb9a3ada58
|
4
|
+
data.tar.gz: 4bace143eab94cf52ff3614854047164eb920426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a77908380e0e8f5babdcf2afcc73d2663e4d743f4c579b27b765b045da571587ddf011ea377ad1319987ca99f03b23d07eb01d359b73bd7d37d0d6e4949863e7
|
7
|
+
data.tar.gz: 558bf4aa7e15fbde87ebadbf343c67915eddd5846f5703cf579c81192b11ceadea8d46281d33e1bc5eac91b739ce643956374c117c69701caa38a027af99a059
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ PostgreSQL output plugins for Embulk loads records to PostgreSQL.
|
|
25
25
|
- **default_timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp into a SQL string. This default_timezone option is used to control the timezone. You can overwrite timezone for each columns using column_options option. (string, default: `UTC`)
|
26
26
|
- **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
|
27
27
|
- **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, truncate_insert and merge modes), when it creates the target table (insert_direct and replace modes), and when it creates nonexistent target table automatically. (string, default: depends on input column type. `BIGINT` if input column type is long, `BOOLEAN` if boolean, `DOUBLE PRECISION` if double, `CLOB` if string, `TIMESTAMP WITH TIME ZONE` if timestamp)
|
28
|
-
- **value_type**: This plugin converts input column type (embulk type) into a database type to build a INSERT statement. This value_type option controls the type of the value in a INSERT statement. (string, default: depends on
|
28
|
+
- **value_type**: This plugin converts input column type (embulk type) into a database type to build a INSERT statement. This value_type option controls the type of the value in a INSERT statement. (string, default: depends on the sql type of the column. Available values options are: `byte`, `short`, `int`, `long`, `double`, `float`, `boolean`, `string`, `nstring`, `date`, `time`, `timestamp`, `decimal`, `json`, `null`, `pass`)
|
29
29
|
- **timestamp_format**: If input column type (embulk type) is timestamp and value_type is `string` or `nstring`, this plugin needs to format the timestamp value into a string. This timestamp_format option is used to control the format of the timestamp. (string, default: `%Y-%m-%d %H:%M:%S.%6N`)
|
30
30
|
- **timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp value into a SQL string. In this cases, this timezone option is used to control the timezone. (string, value of default_timezone option is used by default)
|
31
31
|
|
@@ -52,6 +52,29 @@ PostgreSQL output plugins for Embulk loads records to PostgreSQL.
|
|
52
52
|
* Transactional: Yes.
|
53
53
|
* Resumable: Yes.
|
54
54
|
|
55
|
+
### Supported types
|
56
|
+
|
57
|
+
|database type|default value_type|note|
|
58
|
+
|:--|:--|:--|
|
59
|
+
|bool|boolean||
|
60
|
+
|smallint|short||
|
61
|
+
|int|int||
|
62
|
+
|bigint|long||
|
63
|
+
|real|float||
|
64
|
+
|double precision|double||
|
65
|
+
|money|double||
|
66
|
+
|numeric|decimal||
|
67
|
+
|char|string||
|
68
|
+
|varchar|string||
|
69
|
+
|text|string||
|
70
|
+
|json|json||
|
71
|
+
|jsonb|json||
|
72
|
+
|date|date||
|
73
|
+
|time|time||
|
74
|
+
|timestamp|timestamp||
|
75
|
+
|
76
|
+
You can use other types by specifying `value_type` in `column_options`.
|
77
|
+
|
55
78
|
### Example
|
56
79
|
|
57
80
|
```yaml
|
Binary file
|
Binary file
|
@@ -1,25 +1,29 @@
|
|
1
1
|
package org.embulk.output;
|
2
2
|
|
3
|
-
import java.util.List;
|
4
|
-
import java.util.Properties;
|
5
3
|
import java.io.IOException;
|
6
4
|
import java.sql.SQLException;
|
7
|
-
import
|
8
|
-
import
|
5
|
+
import java.sql.Types;
|
6
|
+
import java.util.List;
|
7
|
+
import java.util.Properties;
|
8
|
+
|
9
9
|
import org.embulk.config.Config;
|
10
10
|
import org.embulk.config.ConfigDefault;
|
11
11
|
import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
|
12
12
|
import org.embulk.output.jdbc.BatchInsert;
|
13
|
-
import org.embulk.output.
|
13
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
14
|
+
import org.embulk.output.jdbc.JdbcSchema;
|
15
|
+
import org.embulk.output.jdbc.setter.ColumnSetterFactory;
|
14
16
|
import org.embulk.output.postgresql.PostgreSQLCopyBatchInsert;
|
17
|
+
import org.embulk.output.postgresql.PostgreSQLOutputConnector;
|
18
|
+
import org.embulk.output.postgresql.setter.PostgreSQLColumnSetterFactory;
|
19
|
+
import org.embulk.spi.Column;
|
20
|
+
import org.embulk.spi.ColumnVisitor;
|
21
|
+
import org.embulk.spi.Schema;
|
22
|
+
import org.joda.time.DateTimeZone;
|
15
23
|
|
24
|
+
import com.google.common.base.Optional;
|
16
25
|
import com.google.common.collect.ImmutableList;
|
17
|
-
import
|
18
|
-
import org.embulk.spi.Schema;
|
19
|
-
import org.embulk.spi.ColumnVisitor;
|
20
|
-
import org.embulk.spi.Column;
|
21
|
-
import org.embulk.output.jdbc.JdbcColumn;
|
22
|
-
import org.embulk.output.jdbc.JdbcSchema;
|
26
|
+
import com.google.common.collect.ImmutableSet;
|
23
27
|
|
24
28
|
public class PostgreSQLOutputPlugin
|
25
29
|
extends AbstractJdbcOutputPlugin
|
@@ -155,7 +159,9 @@ public class PostgreSQLOutputPlugin
|
|
155
159
|
|
156
160
|
public void jsonColumn(Column column)
|
157
161
|
{
|
158
|
-
|
162
|
+
columns.add(JdbcColumn.newGenericTypeColumn(
|
163
|
+
columnName, Types.OTHER, "JSON",
|
164
|
+
4000, 0, false, false)); // TODO size type param
|
159
165
|
}
|
160
166
|
|
161
167
|
public void timestampColumn(Column column)
|
@@ -168,4 +174,10 @@ public class PostgreSQLOutputPlugin
|
|
168
174
|
}
|
169
175
|
return new JdbcSchema(columns.build());
|
170
176
|
}
|
177
|
+
|
178
|
+
@Override
|
179
|
+
protected ColumnSetterFactory newColumnSetterFactory(BatchInsert batch, DateTimeZone defaultTimeZone)
|
180
|
+
{
|
181
|
+
return new PostgreSQLColumnSetterFactory(batch, defaultTimeZone);
|
182
|
+
}
|
171
183
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package org.embulk.output.postgresql.setter;
|
2
|
+
|
3
|
+
import org.embulk.output.jdbc.BatchInsert;
|
4
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
5
|
+
import org.embulk.output.jdbc.JdbcColumnOption;
|
6
|
+
import org.embulk.output.jdbc.setter.ColumnSetter;
|
7
|
+
import org.embulk.output.jdbc.setter.ColumnSetterFactory;
|
8
|
+
import org.embulk.output.jdbc.setter.JsonColumnSetter;
|
9
|
+
import org.joda.time.DateTimeZone;
|
10
|
+
|
11
|
+
public class PostgreSQLColumnSetterFactory
|
12
|
+
extends ColumnSetterFactory
|
13
|
+
{
|
14
|
+
public PostgreSQLColumnSetterFactory(BatchInsert batch, DateTimeZone defaultTimeZone)
|
15
|
+
{
|
16
|
+
super(batch, defaultTimeZone);
|
17
|
+
}
|
18
|
+
|
19
|
+
@Override
|
20
|
+
public ColumnSetter newCoalesceColumnSetter(JdbcColumn column, JdbcColumnOption option)
|
21
|
+
{
|
22
|
+
if (column.getSimpleTypeName().equalsIgnoreCase("json") || column.getSimpleTypeName().equalsIgnoreCase("jsonb")) {
|
23
|
+
// actually "JSON"/"JSONB"
|
24
|
+
return new JsonColumnSetter(batch, column, newDefaultValueSetter(column, option));
|
25
|
+
} else {
|
26
|
+
return super.newCoalesceColumnSetter(column, option);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -25,8 +25,9 @@ files:
|
|
25
25
|
- src/main/java/org/embulk/output/postgresql/PostgreSQLCopyBatchInsert.java
|
26
26
|
- src/main/java/org/embulk/output/postgresql/PostgreSQLOutputConnection.java
|
27
27
|
- src/main/java/org/embulk/output/postgresql/PostgreSQLOutputConnector.java
|
28
|
-
-
|
29
|
-
- classpath/embulk-output-
|
28
|
+
- src/main/java/org/embulk/output/postgresql/setter/PostgreSQLColumnSetterFactory.java
|
29
|
+
- classpath/embulk-output-jdbc-0.6.0.jar
|
30
|
+
- classpath/embulk-output-postgresql-0.6.0.jar
|
30
31
|
- classpath/postgresql-9.4-1205-jdbc41.jar
|
31
32
|
homepage: https://github.com/embulk/embulk-output-jdbc
|
32
33
|
licenses:
|