embulk-input-redshift 0.4.0 → 0.5.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 +90 -62
- data/build.gradle +6 -6
- data/classpath/embulk-input-jdbc-0.5.0.jar +0 -0
- data/classpath/{embulk-input-postgresql-0.4.0.jar → embulk-input-postgresql-0.5.0.jar} +0 -0
- data/classpath/{embulk-input-redshift-0.4.0.jar → embulk-input-redshift-0.5.0.jar} +0 -0
- data/lib/embulk/input/redshift.rb +3 -3
- data/src/main/java/org/embulk/input/RedshiftInputPlugin.java +92 -92
- metadata +5 -5
- data/classpath/embulk-input-jdbc-0.4.0.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d420ce90518a621e71996d2ffc6d8b57246610ac
|
4
|
+
data.tar.gz: 5a3922ea637e1011cb04ea5387c15045d0c95e6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fb1aeb87ce69650ecafd235856384f20aa3d3ea8eea090712178130d212f75c12bc0aff213d9c13334e871f4d7e2690570604b87d9148895fed9df75ada55a1
|
7
|
+
data.tar.gz: 8781224b4ee7d05b52d437b09022edee202f8b1e52543562c00daba7c8d10b98d38ec232534f634f45cdc52dcb5fd4d68846038cbdc50b4bef3c69081245bedc
|
data/README.md
CHANGED
@@ -1,62 +1,90 @@
|
|
1
|
-
# Redshift input plugins for Embulk
|
2
|
-
|
3
|
-
Redshift input plugins for Embulk loads records from Redshift.
|
4
|
-
|
5
|
-
## Overview
|
6
|
-
|
7
|
-
* **Plugin type**: input
|
8
|
-
* **Resume supported**: yes
|
9
|
-
|
10
|
-
## Configuration
|
11
|
-
|
12
|
-
- **host**: database host name (string, required)
|
13
|
-
- **port**: database port number (integer, 5439)
|
14
|
-
- **user**: database login user name (string, required)
|
15
|
-
- **password**: database login password (string, default: "")
|
16
|
-
- **database**: destination database name (string, required)
|
17
|
-
- **schema**: destination schema name (string, default: "public")
|
18
|
-
- **where**: WHERE condition to filter the rows (string, default: no-condition)
|
19
|
-
- **fetch_rows**: number of rows to fetch one time (used for java.sql.Statement#setFetchSize) (integer, default: 10000)
|
20
|
-
- **options**: extra JDBC properties (hash, default: {})
|
21
|
-
- If you write SQL directly,
|
22
|
-
- **query**: SQL to run (string)
|
23
|
-
- If **query** is not set,
|
24
|
-
- **table**: destination table name (string, required)
|
25
|
-
- **select**: comma-separated list of columns to select (string, default: "*")
|
26
|
-
- **where**: WHERE condition to filter the rows (string, default: no-condition)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
```
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
1
|
+
# Redshift input plugins for Embulk
|
2
|
+
|
3
|
+
Redshift input plugins for Embulk loads records from Redshift.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: input
|
8
|
+
* **Resume supported**: yes
|
9
|
+
|
10
|
+
## Configuration
|
11
|
+
|
12
|
+
- **host**: database host name (string, required)
|
13
|
+
- **port**: database port number (integer, 5439)
|
14
|
+
- **user**: database login user name (string, required)
|
15
|
+
- **password**: database login password (string, default: "")
|
16
|
+
- **database**: destination database name (string, required)
|
17
|
+
- **schema**: destination schema name (string, default: "public")
|
18
|
+
- **where**: WHERE condition to filter the rows (string, default: no-condition)
|
19
|
+
- **fetch_rows**: number of rows to fetch one time (used for java.sql.Statement#setFetchSize) (integer, default: 10000)
|
20
|
+
- **options**: extra JDBC properties (hash, default: {})
|
21
|
+
- If you write SQL directly,
|
22
|
+
- **query**: SQL to run (string)
|
23
|
+
- If **query** is not set,
|
24
|
+
- **table**: destination table name (string, required)
|
25
|
+
- **select**: comma-separated list of columns to select (string, default: "*")
|
26
|
+
- **where**: WHERE condition to filter the rows (string, default: no-condition)
|
27
|
+
- **default_timezone**: If the sql type of a column is `date`/`time`/`datetime` and the embulk type is `string`, column values are formatted int this default_timezone. You can overwrite timezone for each columns using column_options option. (string, default: `UTC`)
|
28
|
+
- **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
|
29
|
+
- **value_type**: embulk get values from database as this value_type. Typically, the value_type determines `getXXX` method of `java.sql.PreparedStatement`.
|
30
|
+
(string, default: depends on the sql type of the column. Available values options are: `long`, `double`, `float`, `decimal`, `boolean`, `string`, `date`, `time`, `timestamp`)
|
31
|
+
- **type**: Column values are converted to this embulk type.
|
32
|
+
Available values options are: `boolean`, `long`, `double`, `string`, `timestamp`).
|
33
|
+
By default, the embulk type is determined according to the sql type of the column (or value_type if specified).
|
34
|
+
- **timestamp_format**: If the sql type of the column is `date`/`time`/`datetime` and the embulk type is `string`, column values are formatted by this timestamp_format. And if the embulk type is `timestamp`, this timestamp_format will be used in the output plugin. (string, default : `%Y-%m-%d` for `date`, `%H:%M:%S` for `time`, `%Y-%m-%d %H:%M:%S` for `timestamp`)
|
35
|
+
- **timezone**: If the sql type of the column is `date`/`time`/`datetime` and the embulk type is `string`, column values are formatted in this timezone.
|
36
|
+
(string, value of default_timezone option is used by default)
|
37
|
+
|
38
|
+
## Example
|
39
|
+
|
40
|
+
```yaml
|
41
|
+
in:
|
42
|
+
type: redshift
|
43
|
+
host: localhost
|
44
|
+
user: myuser
|
45
|
+
password: ""
|
46
|
+
database: my_database
|
47
|
+
table: my_table
|
48
|
+
select: "col1, col2, col3"
|
49
|
+
where: "col4 != 'a'"
|
50
|
+
```
|
51
|
+
|
52
|
+
If you need a complex SQL,
|
53
|
+
|
54
|
+
```yaml
|
55
|
+
in:
|
56
|
+
type: redshift
|
57
|
+
host: localhost
|
58
|
+
user: myuser
|
59
|
+
password: ""
|
60
|
+
database: my_database
|
61
|
+
query: |
|
62
|
+
SELECT t1.id, t1.name, t2.id AS t2_id, t2.name AS t2_name
|
63
|
+
FROM table1 AS t1
|
64
|
+
LEFT JOIN table2 AS t2
|
65
|
+
ON t1.id = t2.t1_id
|
66
|
+
```
|
67
|
+
|
68
|
+
Advanced configuration:
|
69
|
+
|
70
|
+
```yaml
|
71
|
+
in:
|
72
|
+
type: redshift
|
73
|
+
host: localhost
|
74
|
+
user: myuser
|
75
|
+
password: ""
|
76
|
+
database: my_database
|
77
|
+
table: "my_table"
|
78
|
+
select: "col1, col2, col3"
|
79
|
+
where: "col4 != 'a'"
|
80
|
+
column_options:
|
81
|
+
col1: {type: long}
|
82
|
+
col3: {type: string, timestamp_format: "%Y/%m/%d", timezone: "+0900"}
|
83
|
+
|
84
|
+
```
|
85
|
+
|
86
|
+
## Build
|
87
|
+
|
88
|
+
```
|
89
|
+
$ ./gradlew gem
|
90
|
+
```
|
data/build.gradle
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
dependencies {
|
2
|
-
compile project(':embulk-input-jdbc')
|
3
|
-
compile project(':embulk-input-postgresql')
|
4
|
-
|
5
|
-
testCompile project(':embulk-input-jdbc').sourceSets.test.output
|
6
|
-
}
|
1
|
+
dependencies {
|
2
|
+
compile project(':embulk-input-jdbc')
|
3
|
+
compile project(':embulk-input-postgresql')
|
4
|
+
|
5
|
+
testCompile project(':embulk-input-jdbc').sourceSets.test.output
|
6
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,3 +1,3 @@
|
|
1
|
-
Embulk::JavaPlugin.register_input(
|
2
|
-
:redshift, "org.embulk.input.RedshiftInputPlugin",
|
3
|
-
File.expand_path('../../../../classpath', __FILE__))
|
1
|
+
Embulk::JavaPlugin.register_input(
|
2
|
+
:redshift, "org.embulk.input.RedshiftInputPlugin",
|
3
|
+
File.expand_path('../../../../classpath', __FILE__))
|
@@ -1,92 +1,92 @@
|
|
1
|
-
package org.embulk.input;
|
2
|
-
|
3
|
-
import java.util.Properties;
|
4
|
-
import java.sql.Connection;
|
5
|
-
import java.sql.Driver;
|
6
|
-
import java.sql.SQLException;
|
7
|
-
import com.google.common.base.Throwables;
|
8
|
-
import org.embulk.config.Config;
|
9
|
-
import org.embulk.config.ConfigDefault;
|
10
|
-
import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
|
11
|
-
import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
|
12
|
-
import org.embulk.input.postgresql.PostgreSQLInputConnection;
|
13
|
-
|
14
|
-
public class RedshiftInputPlugin
|
15
|
-
extends AbstractJdbcInputPlugin
|
16
|
-
{
|
17
|
-
private static final Driver driver = new org.postgresql.Driver();
|
18
|
-
|
19
|
-
public interface RedshiftPluginTask
|
20
|
-
extends PluginTask
|
21
|
-
{
|
22
|
-
@Config("host")
|
23
|
-
public String getHost();
|
24
|
-
|
25
|
-
@Config("port")
|
26
|
-
@ConfigDefault("5439")
|
27
|
-
public int getPort();
|
28
|
-
|
29
|
-
@Config("user")
|
30
|
-
public String getUser();
|
31
|
-
|
32
|
-
@Config("password")
|
33
|
-
@ConfigDefault("\"\"")
|
34
|
-
public String getPassword();
|
35
|
-
|
36
|
-
@Config("database")
|
37
|
-
public String getDatabase();
|
38
|
-
|
39
|
-
@Config("schema")
|
40
|
-
@ConfigDefault("\"public\"")
|
41
|
-
public String getSchema();
|
42
|
-
}
|
43
|
-
|
44
|
-
@Override
|
45
|
-
protected Class<? extends PluginTask> getTaskClass()
|
46
|
-
{
|
47
|
-
return RedshiftPluginTask.class;
|
48
|
-
}
|
49
|
-
|
50
|
-
@Override
|
51
|
-
protected PostgreSQLInputConnection newConnection(PluginTask task) throws SQLException
|
52
|
-
{
|
53
|
-
RedshiftPluginTask t = (RedshiftPluginTask) task;
|
54
|
-
|
55
|
-
String url = String.format("jdbc:postgresql://%s:%d/%s",
|
56
|
-
t.getHost(), t.getPort(), t.getDatabase());
|
57
|
-
|
58
|
-
Properties props = new Properties();
|
59
|
-
props.setProperty("user", t.getUser());
|
60
|
-
props.setProperty("password", t.getPassword());
|
61
|
-
props.setProperty("loginTimeout", "300"); // seconds
|
62
|
-
props.setProperty("socketTimeout", "1800"); // seconds
|
63
|
-
|
64
|
-
// Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
|
65
|
-
// Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
|
66
|
-
props.setProperty("tcpKeepAlive", "true");
|
67
|
-
|
68
|
-
// TODO
|
69
|
-
//switch t.getSssl() {
|
70
|
-
//when "disable":
|
71
|
-
// break;
|
72
|
-
//when "enable":
|
73
|
-
// props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); // disable server-side validation
|
74
|
-
//when "verify":
|
75
|
-
// props.setProperty("ssl", "true");
|
76
|
-
// break;
|
77
|
-
//}
|
78
|
-
|
79
|
-
props.putAll(t.getOptions());
|
80
|
-
|
81
|
-
Connection con = driver.connect(url, props);
|
82
|
-
try {
|
83
|
-
PostgreSQLInputConnection c = new PostgreSQLInputConnection(con, t.getSchema());
|
84
|
-
con = null;
|
85
|
-
return c;
|
86
|
-
} finally {
|
87
|
-
if (con != null) {
|
88
|
-
con.close();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
1
|
+
package org.embulk.input;
|
2
|
+
|
3
|
+
import java.util.Properties;
|
4
|
+
import java.sql.Connection;
|
5
|
+
import java.sql.Driver;
|
6
|
+
import java.sql.SQLException;
|
7
|
+
import com.google.common.base.Throwables;
|
8
|
+
import org.embulk.config.Config;
|
9
|
+
import org.embulk.config.ConfigDefault;
|
10
|
+
import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
|
11
|
+
import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
|
12
|
+
import org.embulk.input.postgresql.PostgreSQLInputConnection;
|
13
|
+
|
14
|
+
public class RedshiftInputPlugin
|
15
|
+
extends AbstractJdbcInputPlugin
|
16
|
+
{
|
17
|
+
private static final Driver driver = new org.postgresql.Driver();
|
18
|
+
|
19
|
+
public interface RedshiftPluginTask
|
20
|
+
extends PluginTask
|
21
|
+
{
|
22
|
+
@Config("host")
|
23
|
+
public String getHost();
|
24
|
+
|
25
|
+
@Config("port")
|
26
|
+
@ConfigDefault("5439")
|
27
|
+
public int getPort();
|
28
|
+
|
29
|
+
@Config("user")
|
30
|
+
public String getUser();
|
31
|
+
|
32
|
+
@Config("password")
|
33
|
+
@ConfigDefault("\"\"")
|
34
|
+
public String getPassword();
|
35
|
+
|
36
|
+
@Config("database")
|
37
|
+
public String getDatabase();
|
38
|
+
|
39
|
+
@Config("schema")
|
40
|
+
@ConfigDefault("\"public\"")
|
41
|
+
public String getSchema();
|
42
|
+
}
|
43
|
+
|
44
|
+
@Override
|
45
|
+
protected Class<? extends PluginTask> getTaskClass()
|
46
|
+
{
|
47
|
+
return RedshiftPluginTask.class;
|
48
|
+
}
|
49
|
+
|
50
|
+
@Override
|
51
|
+
protected PostgreSQLInputConnection newConnection(PluginTask task) throws SQLException
|
52
|
+
{
|
53
|
+
RedshiftPluginTask t = (RedshiftPluginTask) task;
|
54
|
+
|
55
|
+
String url = String.format("jdbc:postgresql://%s:%d/%s",
|
56
|
+
t.getHost(), t.getPort(), t.getDatabase());
|
57
|
+
|
58
|
+
Properties props = new Properties();
|
59
|
+
props.setProperty("user", t.getUser());
|
60
|
+
props.setProperty("password", t.getPassword());
|
61
|
+
props.setProperty("loginTimeout", "300"); // seconds
|
62
|
+
props.setProperty("socketTimeout", "1800"); // seconds
|
63
|
+
|
64
|
+
// Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
|
65
|
+
// Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
|
66
|
+
props.setProperty("tcpKeepAlive", "true");
|
67
|
+
|
68
|
+
// TODO
|
69
|
+
//switch t.getSssl() {
|
70
|
+
//when "disable":
|
71
|
+
// break;
|
72
|
+
//when "enable":
|
73
|
+
// props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); // disable server-side validation
|
74
|
+
//when "verify":
|
75
|
+
// props.setProperty("ssl", "true");
|
76
|
+
// break;
|
77
|
+
//}
|
78
|
+
|
79
|
+
props.putAll(t.getOptions());
|
80
|
+
|
81
|
+
Connection con = driver.connect(url, props);
|
82
|
+
try {
|
83
|
+
PostgreSQLInputConnection c = new PostgreSQLInputConnection(con, t.getSchema());
|
84
|
+
con = null;
|
85
|
+
return c;
|
86
|
+
} finally {
|
87
|
+
if (con != null) {
|
88
|
+
con.close();
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-redshift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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: 2015-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Selects records from a table.
|
14
14
|
email:
|
@@ -21,9 +21,9 @@ files:
|
|
21
21
|
- build.gradle
|
22
22
|
- lib/embulk/input/redshift.rb
|
23
23
|
- src/main/java/org/embulk/input/RedshiftInputPlugin.java
|
24
|
-
- classpath/embulk-input-jdbc-0.
|
25
|
-
- classpath/embulk-input-postgresql-0.
|
26
|
-
- classpath/embulk-input-redshift-0.
|
24
|
+
- classpath/embulk-input-jdbc-0.5.0.jar
|
25
|
+
- classpath/embulk-input-postgresql-0.5.0.jar
|
26
|
+
- classpath/embulk-input-redshift-0.5.0.jar
|
27
27
|
- classpath/jna-4.1.0.jar
|
28
28
|
- classpath/jna-platform-4.1.0.jar
|
29
29
|
- classpath/postgresql-9.4-1200-jdbc41.jar
|
Binary file
|