embulk-input-oracle 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/classpath/{embulk-input-jdbc-0.7.1.jar → embulk-input-jdbc-0.7.2.jar} +0 -0
- data/classpath/{embulk-input-oracle-0.7.1.jar → embulk-input-oracle-0.7.2.jar} +0 -0
- data/src/test/java/org/embulk/input/oracle/OracleInputPluginTest.java +189 -0
- data/src/test/resources/oracle/yml/input-column-options-lower.yml +19 -0
- data/src/test/resources/oracle/yml/input-column-options.yml +19 -0
- data/src/test/resources/oracle/yml/input-lower.yml +20 -0
- data/src/test/resources/oracle/yml/input-query-lower.yml +18 -0
- data/src/test/resources/oracle/yml/input-query.yml +18 -0
- data/src/test/resources/oracle/yml/input.yml +20 -0
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c21c11eb15503dc7d9b5a9622f624d31c5d61682
|
4
|
+
data.tar.gz: df349b10fe41bdd359ba49c7748f3726cc614516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c81d15fbbeb6db3cc7681860c314075aa868290deb6622753ca63a54cec6e18a220a2609b25c8fc3f2baa9d5f776fb98ac2bbb1486362d5f94ee3151664f36cc
|
7
|
+
data.tar.gz: d640fe70107b0a5b218cfc7437c7bc406b300d9f87f3cbdd45788429e229db465a6491a00f6b21311c351ce94ce293734870d0ca50cde447ee34ad9fe17ffaa6
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Oracle input plugins for Embulk loads records from Oracle.
|
|
23
23
|
- **table**: destination table name (string, required)
|
24
24
|
- **select**: comma-separated list of columns to select (string, default: "*")
|
25
25
|
- **where**: WHERE condition to filter the rows (string, default: no-condition)
|
26
|
+
- **order_by**: name of the column that rows are sorted by (string, default: not sorted)
|
26
27
|
- **fetch_rows**: number of rows to fetch one time (used for java.sql.Statement#setFetchSize) (integer, default: 10000)
|
27
28
|
- **connect_timeout**: timeout for establishment of a database connection. (integer (seconds), default: 300)
|
28
29
|
- **socket_timeout**: timeout for socket read operations. (integer (seconds), default: 1800)
|
Binary file
|
Binary file
|
@@ -0,0 +1,189 @@
|
|
1
|
+
package org.embulk.input.oracle;
|
2
|
+
|
3
|
+
import static org.junit.Assert.assertEquals;
|
4
|
+
|
5
|
+
import java.io.File;
|
6
|
+
import java.io.IOException;
|
7
|
+
import java.net.URISyntaxException;
|
8
|
+
import java.nio.charset.Charset;
|
9
|
+
import java.nio.file.FileSystem;
|
10
|
+
import java.nio.file.FileSystems;
|
11
|
+
import java.nio.file.Files;
|
12
|
+
import java.sql.Connection;
|
13
|
+
import java.sql.DriverManager;
|
14
|
+
import java.sql.SQLException;
|
15
|
+
import java.sql.Statement;
|
16
|
+
import java.util.Arrays;
|
17
|
+
import java.util.List;
|
18
|
+
|
19
|
+
import org.embulk.input.EmbulkPluginTester;
|
20
|
+
import org.embulk.input.OracleInputPlugin;
|
21
|
+
import org.embulk.spi.InputPlugin;
|
22
|
+
import org.junit.AfterClass;
|
23
|
+
import org.junit.BeforeClass;
|
24
|
+
import org.junit.Test;
|
25
|
+
|
26
|
+
public class OracleInputPluginTest
|
27
|
+
{
|
28
|
+
private static boolean prepared = false;
|
29
|
+
private static EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "oracle", OracleInputPlugin.class);
|
30
|
+
|
31
|
+
@BeforeClass
|
32
|
+
public static void prepare() throws SQLException
|
33
|
+
{
|
34
|
+
Connection connection;
|
35
|
+
try {
|
36
|
+
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/TESTDB", "TEST_USER", "test_pw");
|
37
|
+
} catch (SQLException e) {
|
38
|
+
System.err.println(e);
|
39
|
+
System.err.println("Warning: prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw').");
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
|
43
|
+
try {
|
44
|
+
try (Statement statement = connection.createStatement()) {
|
45
|
+
String drop1 = "DROP TABLE TEST1";
|
46
|
+
try {
|
47
|
+
statement.execute(drop1);
|
48
|
+
} catch (SQLException e) {
|
49
|
+
System.out.println(e);
|
50
|
+
}
|
51
|
+
|
52
|
+
String create1 =
|
53
|
+
"CREATE TABLE TEST1 ("
|
54
|
+
+ "C1 DECIMAL(12,2),"
|
55
|
+
+ "C2 CHAR(8),"
|
56
|
+
+ "C3 VARCHAR2(8),"
|
57
|
+
+ "C4 NVARCHAR2(8),"
|
58
|
+
+ "C5 DATE,"
|
59
|
+
+ "C6 TIMESTAMP,"
|
60
|
+
+ "C7 TIMESTAMP(3))";
|
61
|
+
statement.execute(create1);
|
62
|
+
|
63
|
+
String insert1 =
|
64
|
+
"INSERT INTO TEST1 VALUES("
|
65
|
+
+ "NULL,"
|
66
|
+
+ "NULL,"
|
67
|
+
+ "NULL,"
|
68
|
+
+ "NULL,"
|
69
|
+
+ "NULL,"
|
70
|
+
+ "NULL,"
|
71
|
+
+ "NULL)";
|
72
|
+
statement.executeUpdate(insert1);
|
73
|
+
|
74
|
+
String insert2 =
|
75
|
+
"INSERT INTO TEST1 VALUES("
|
76
|
+
+ "-1234567890.12,"
|
77
|
+
+ "'ABCDEF',"
|
78
|
+
+ "'XYZ',"
|
79
|
+
+ "'ABCDEFGH',"
|
80
|
+
+ "'2015-06-04',"
|
81
|
+
+ "'2015-06-05 23:45:06',"
|
82
|
+
+ "'2015-06-06 23:45:06.789')";
|
83
|
+
statement.executeUpdate(insert2);
|
84
|
+
}
|
85
|
+
|
86
|
+
} finally {
|
87
|
+
connection.close();
|
88
|
+
prepared = true;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
@AfterClass
|
93
|
+
public static void dispose()
|
94
|
+
{
|
95
|
+
tester.destroy();
|
96
|
+
}
|
97
|
+
|
98
|
+
@Test
|
99
|
+
public void test() throws Exception
|
100
|
+
{
|
101
|
+
if (prepared) {
|
102
|
+
tester.run(convertPath("/oracle/yml/input.yml"));
|
103
|
+
assertEquals(Arrays.asList(
|
104
|
+
"C1,C2,C3,C4,C5,C6,C7",
|
105
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
|
106
|
+
",,,,,,"),
|
107
|
+
read("oracle-input000.00.csv"));
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
@Test
|
112
|
+
public void testLower() throws Exception
|
113
|
+
{
|
114
|
+
if (prepared) {
|
115
|
+
tester.run(convertPath("/oracle/yml/input-lower.yml"));
|
116
|
+
assertEquals(Arrays.asList(
|
117
|
+
"C1,C2,C3,C4,C5,C6,C7",
|
118
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
|
119
|
+
",,,,,,"),
|
120
|
+
read("oracle-input000.00.csv"));
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
@Test
|
125
|
+
public void testQuery() throws Exception
|
126
|
+
{
|
127
|
+
if (prepared) {
|
128
|
+
tester.run(convertPath("/oracle/yml/input-query.yml"));
|
129
|
+
assertEquals(Arrays.asList(
|
130
|
+
"C1,C2,C3,C4,C5,C6,C7",
|
131
|
+
",,,,,,",
|
132
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789"),
|
133
|
+
read("oracle-input000.00.csv"));
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
@Test
|
138
|
+
public void testQueryLower() throws Exception
|
139
|
+
{
|
140
|
+
if (prepared) {
|
141
|
+
tester.run(convertPath("/oracle/yml/input-query-lower.yml"));
|
142
|
+
assertEquals(Arrays.asList(
|
143
|
+
"C1,C2,C3,C4,C5,C6,C7",
|
144
|
+
",,,,,,",
|
145
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789"),
|
146
|
+
read("oracle-input000.00.csv"));
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
@Test
|
151
|
+
public void testColumnOptions() throws Exception
|
152
|
+
{
|
153
|
+
if (prepared) {
|
154
|
+
tester.run(convertPath("/oracle/yml/input-column-options.yml"));
|
155
|
+
assertEquals(Arrays.asList(
|
156
|
+
"C1,C2,C3,C4,C5,C6,C7",
|
157
|
+
",,,,,,",
|
158
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
|
159
|
+
read("oracle-input000.00.csv"));
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
@Test
|
164
|
+
public void testColumnOptionsLower() throws Exception
|
165
|
+
{
|
166
|
+
if (prepared) {
|
167
|
+
tester.run(convertPath("/oracle/yml/input-column-options-lower.yml"));
|
168
|
+
assertEquals(Arrays.asList(
|
169
|
+
"C1,C2,C3,C4,C5,C6,C7",
|
170
|
+
",,,,,,",
|
171
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
|
172
|
+
read("oracle-input000.00.csv"));
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
private List<String> read(String path) throws IOException
|
177
|
+
{
|
178
|
+
FileSystem fs = FileSystems.getDefault();
|
179
|
+
return Files.readAllLines(fs.getPath(path), Charset.defaultCharset());
|
180
|
+
}
|
181
|
+
|
182
|
+
private String convertPath(String name) throws URISyntaxException
|
183
|
+
{
|
184
|
+
if (getClass().getResource(name) == null) {
|
185
|
+
return name;
|
186
|
+
}
|
187
|
+
return new File(getClass().getResource(name).toURI()).getAbsolutePath();
|
188
|
+
}
|
189
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
in:
|
2
|
+
type: oracle
|
3
|
+
host: localhost
|
4
|
+
database: TESTDB
|
5
|
+
user: TEST_USER
|
6
|
+
password: test_pw
|
7
|
+
table: TEST1
|
8
|
+
select: "*"
|
9
|
+
column_options:
|
10
|
+
c5: {type: string, timestamp_format: '%Y/%m/%d', timezone: "+0900"}
|
11
|
+
c6: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S', timezone: "+0900"}
|
12
|
+
c7: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S.%3N', timezone: "+0900"}
|
13
|
+
|
14
|
+
out:
|
15
|
+
type: file
|
16
|
+
path_prefix: oracle-input
|
17
|
+
file_ext: csv
|
18
|
+
formatter:
|
19
|
+
type: csv
|
@@ -0,0 +1,19 @@
|
|
1
|
+
in:
|
2
|
+
type: oracle
|
3
|
+
host: localhost
|
4
|
+
database: TESTDB
|
5
|
+
user: TEST_USER
|
6
|
+
password: test_pw
|
7
|
+
table: TEST1
|
8
|
+
select: "*"
|
9
|
+
column_options:
|
10
|
+
C5: {type: string, timestamp_format: '%Y/%m/%d', timezone: "+0900"}
|
11
|
+
C6: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S', timezone: "+0900"}
|
12
|
+
C7: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S.%3N', timezone: "+0900"}
|
13
|
+
|
14
|
+
out:
|
15
|
+
type: file
|
16
|
+
path_prefix: oracle-input
|
17
|
+
file_ext: csv
|
18
|
+
formatter:
|
19
|
+
type: csv
|
@@ -0,0 +1,20 @@
|
|
1
|
+
in:
|
2
|
+
type: oracle
|
3
|
+
host: localhost
|
4
|
+
database: TESTDB
|
5
|
+
user: TEST_USER
|
6
|
+
password: test_pw
|
7
|
+
table: test1
|
8
|
+
select: "c1, c2, c3, c4, c5, c6, c7"
|
9
|
+
order_by: c1
|
10
|
+
|
11
|
+
out:
|
12
|
+
type: file
|
13
|
+
path_prefix: oracle-input
|
14
|
+
file_ext: csv
|
15
|
+
formatter:
|
16
|
+
type: csv
|
17
|
+
column_options:
|
18
|
+
C5: {format: '%Y-%m-%d', timezone: '+0900'}
|
19
|
+
C6: {format: '%Y-%m-%d %H:%M:%S', timezone: '+0900'}
|
20
|
+
C7: {format: '%Y-%m-%d %H:%M:%S.%3N', timezone: '+0900'}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
in:
|
2
|
+
type: oracle
|
3
|
+
host: localhost
|
4
|
+
database: TESTDB
|
5
|
+
user: TEST_USER
|
6
|
+
password: test_pw
|
7
|
+
query: "select c1, c2, c3, c4, c5, c6, c7 from test1"
|
8
|
+
|
9
|
+
out:
|
10
|
+
type: file
|
11
|
+
path_prefix: oracle-input
|
12
|
+
file_ext: csv
|
13
|
+
formatter:
|
14
|
+
type: csv
|
15
|
+
column_options:
|
16
|
+
C5: {format: '%Y-%m-%d', timezone: '+0900'}
|
17
|
+
C6: {format: '%Y-%m-%d %H:%M:%S', timezone: '+0900'}
|
18
|
+
C7: {format: '%Y-%m-%d %H:%M:%S.%3N', timezone: '+0900'}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
in:
|
2
|
+
type: oracle
|
3
|
+
host: localhost
|
4
|
+
database: TESTDB
|
5
|
+
user: TEST_USER
|
6
|
+
password: test_pw
|
7
|
+
query: "SELECT C1, C2, C3, C4, C5, C6, C7 FROM TEST1"
|
8
|
+
|
9
|
+
out:
|
10
|
+
type: file
|
11
|
+
path_prefix: oracle-input
|
12
|
+
file_ext: csv
|
13
|
+
formatter:
|
14
|
+
type: csv
|
15
|
+
column_options:
|
16
|
+
C5: {format: '%Y-%m-%d', timezone: '+0900'}
|
17
|
+
C6: {format: '%Y-%m-%d %H:%M:%S', timezone: '+0900'}
|
18
|
+
C7: {format: '%Y-%m-%d %H:%M:%S.%3N', timezone: '+0900'}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
in:
|
2
|
+
type: oracle
|
3
|
+
host: localhost
|
4
|
+
database: TESTDB
|
5
|
+
user: TEST_USER
|
6
|
+
password: test_pw
|
7
|
+
table: TEST1
|
8
|
+
select: "C1, C2, C3, C4, C5, C6, C7"
|
9
|
+
order_by: C1
|
10
|
+
|
11
|
+
out:
|
12
|
+
type: file
|
13
|
+
path_prefix: oracle-input
|
14
|
+
file_ext: csv
|
15
|
+
formatter:
|
16
|
+
type: csv
|
17
|
+
column_options:
|
18
|
+
C5: {format: '%Y-%m-%d', timezone: '+0900'}
|
19
|
+
C6: {format: '%Y-%m-%d %H:%M:%S', timezone: '+0900'}
|
20
|
+
C7: {format: '%Y-%m-%d %H:%M:%S.%3N', timezone: '+0900'}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-oracle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
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-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Selects records from a table.
|
14
14
|
email:
|
@@ -22,8 +22,15 @@ files:
|
|
22
22
|
- lib/embulk/input/oracle.rb
|
23
23
|
- src/main/java/org/embulk/input/OracleInputPlugin.java
|
24
24
|
- src/main/java/org/embulk/input/oracle/OracleInputConnection.java
|
25
|
-
-
|
26
|
-
-
|
25
|
+
- src/test/java/org/embulk/input/oracle/OracleInputPluginTest.java
|
26
|
+
- src/test/resources/oracle/yml/input-column-options-lower.yml
|
27
|
+
- src/test/resources/oracle/yml/input-column-options.yml
|
28
|
+
- src/test/resources/oracle/yml/input-lower.yml
|
29
|
+
- src/test/resources/oracle/yml/input-query-lower.yml
|
30
|
+
- src/test/resources/oracle/yml/input-query.yml
|
31
|
+
- src/test/resources/oracle/yml/input.yml
|
32
|
+
- classpath/embulk-input-jdbc-0.7.2.jar
|
33
|
+
- classpath/embulk-input-oracle-0.7.2.jar
|
27
34
|
homepage: https://github.com/embulk/embulk-input-jdbc
|
28
35
|
licenses:
|
29
36
|
- Apache 2.0
|