embulk-input-oracle 0.7.4 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/classpath/{embulk-input-jdbc-0.7.4.jar → embulk-input-jdbc-0.8.0.jar} +0 -0
- data/classpath/{embulk-input-oracle-0.7.4.jar → embulk-input-oracle-0.8.0.jar} +0 -0
- data/src/test/java/org/embulk/input/oracle/OracleInputPluginTest.java +80 -107
- data/src/test/resources/oracle/yml/input-column-options-lower.yml +5 -4
- data/src/test/resources/oracle/yml/input-column-options.yml +5 -4
- data/src/test/resources/oracle/yml/input-lower.yml +4 -4
- data/src/test/resources/oracle/yml/input-query-lower.yml +5 -5
- data/src/test/resources/oracle/yml/input-query.yml +5 -5
- data/src/test/resources/oracle/yml/input.yml +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab1f91c076cf91ec74900b6a463ad07abd8647b2
|
4
|
+
data.tar.gz: 2dc1d750ad0cd880de15893f3bf1222b4859521a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f65aff4ca8d4f34bbfac2b33a81dd315f68f4db9f01bb00147abad57df7f373d7c3807cb05391be979095356f82fef89710eaf087a1539553ea73ac2ea96404
|
7
|
+
data.tar.gz: 59e3ab2f6ee38e5eb7b72c96bb73b056246bcdcfc628e52031de3fb213cdcb7e8626edd01d867aa6ce10b7a4cabd826c014d257a0cb5793312fbf89855c68a6f
|
data/README.md
CHANGED
Binary file
|
Binary file
|
@@ -1,36 +1,25 @@
|
|
1
1
|
package org.embulk.input.oracle;
|
2
2
|
|
3
|
+
import static java.util.Locale.ENGLISH;
|
3
4
|
import static org.junit.Assert.assertEquals;
|
4
5
|
|
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
6
|
import java.sql.Connection;
|
13
7
|
import java.sql.DriverManager;
|
14
8
|
import java.sql.SQLException;
|
15
|
-
import java.sql.Statement;
|
16
9
|
import java.util.Arrays;
|
17
|
-
import java.util.List;
|
18
10
|
|
19
|
-
import org.embulk.input.
|
11
|
+
import org.embulk.input.AbstractJdbcInputPluginTest;
|
20
12
|
import org.embulk.input.OracleInputPlugin;
|
21
13
|
import org.embulk.spi.InputPlugin;
|
22
|
-
import org.junit.AfterClass;
|
23
|
-
import org.junit.BeforeClass;
|
24
14
|
import org.junit.Test;
|
25
15
|
|
26
|
-
public class OracleInputPluginTest
|
16
|
+
public class OracleInputPluginTest extends AbstractJdbcInputPluginTest
|
27
17
|
{
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@BeforeClass
|
32
|
-
public static void prepare() throws SQLException
|
18
|
+
@Override
|
19
|
+
protected void prepare() throws SQLException
|
33
20
|
{
|
21
|
+
tester.addPlugin(InputPlugin.class, "oracle", OracleInputPlugin.class);
|
22
|
+
|
34
23
|
try {
|
35
24
|
Class.forName("oracle.jdbc.OracleDriver");
|
36
25
|
} catch (ClassNotFoundException e) {
|
@@ -38,75 +27,66 @@ public class OracleInputPluginTest
|
|
38
27
|
return;
|
39
28
|
}
|
40
29
|
|
41
|
-
Connection connection;
|
42
30
|
try {
|
43
|
-
|
31
|
+
connect();
|
44
32
|
} catch (SQLException e) {
|
45
33
|
System.err.println(e);
|
46
|
-
System.err.println("Warning: prepare a schema on Oracle (database =
|
34
|
+
System.err.println(String.format(ENGLISH, "Warning: prepare a schema on Oracle 12c (server = %s, port = %d, database = %s, user = %s, password = %s, charset = UTF-8).",
|
35
|
+
getHost(), getPort(), getDatabase(), getUser(), getPassword()));
|
36
|
+
// for example
|
37
|
+
// CREATE USER TEST_USER IDENTIFIED BY "test_pw";
|
38
|
+
// GRANT DBA TO TEST_USER;
|
47
39
|
return;
|
48
40
|
}
|
49
41
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
} finally {
|
94
|
-
connection.close();
|
95
|
-
prepared = true;
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
@AfterClass
|
100
|
-
public static void dispose()
|
101
|
-
{
|
102
|
-
tester.destroy();
|
42
|
+
enabled = true;
|
43
|
+
|
44
|
+
String drop1 = "DROP TABLE TEST1";
|
45
|
+
executeSQL(drop1, true);
|
46
|
+
|
47
|
+
String create1 =
|
48
|
+
"CREATE TABLE TEST1 ("
|
49
|
+
+ "ID CHAR(2),"
|
50
|
+
+ "C1 DECIMAL(12,2),"
|
51
|
+
+ "C2 CHAR(8),"
|
52
|
+
+ "C3 VARCHAR2(8),"
|
53
|
+
+ "C4 NVARCHAR2(8),"
|
54
|
+
+ "C5 DATE,"
|
55
|
+
+ "C6 TIMESTAMP,"
|
56
|
+
+ "C7 TIMESTAMP(3),"
|
57
|
+
+ "PRIMARY KEY(ID))";
|
58
|
+
executeSQL(create1);
|
59
|
+
|
60
|
+
String insert1 =
|
61
|
+
"INSERT INTO TEST1 VALUES("
|
62
|
+
+ "'10',"
|
63
|
+
+ "NULL,"
|
64
|
+
+ "NULL,"
|
65
|
+
+ "NULL,"
|
66
|
+
+ "NULL,"
|
67
|
+
+ "NULL,"
|
68
|
+
+ "NULL,"
|
69
|
+
+ "NULL)";
|
70
|
+
executeSQL(insert1);
|
71
|
+
|
72
|
+
String insert2 =
|
73
|
+
"INSERT INTO TEST1 VALUES("
|
74
|
+
+ "'11',"
|
75
|
+
+ "-1234567890.12,"
|
76
|
+
+ "'ABCDEF',"
|
77
|
+
+ "'XYZ',"
|
78
|
+
+ "'ABCDEFGH',"
|
79
|
+
+ "'2015-06-04',"
|
80
|
+
+ "'2015-06-05 23:45:06',"
|
81
|
+
+ "'2015-06-06 23:45:06.789')";
|
82
|
+
executeSQL(insert2);
|
103
83
|
}
|
104
84
|
|
105
85
|
@Test
|
106
86
|
public void test() throws Exception
|
107
87
|
{
|
108
|
-
if (
|
109
|
-
|
88
|
+
if (enabled) {
|
89
|
+
test("/oracle/yml/input.yml");
|
110
90
|
assertEquals(Arrays.asList(
|
111
91
|
"C1,C2,C3,C4,C5,C6,C7",
|
112
92
|
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
|
@@ -118,8 +98,8 @@ public class OracleInputPluginTest
|
|
118
98
|
@Test
|
119
99
|
public void testLower() throws Exception
|
120
100
|
{
|
121
|
-
if (
|
122
|
-
|
101
|
+
if (enabled) {
|
102
|
+
test("/oracle/yml/input-lower.yml");
|
123
103
|
assertEquals(Arrays.asList(
|
124
104
|
"C1,C2,C3,C4,C5,C6,C7",
|
125
105
|
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
|
@@ -131,12 +111,12 @@ public class OracleInputPluginTest
|
|
131
111
|
@Test
|
132
112
|
public void testQuery() throws Exception
|
133
113
|
{
|
134
|
-
if (
|
135
|
-
|
114
|
+
if (enabled) {
|
115
|
+
test("/oracle/yml/input-query.yml");
|
136
116
|
assertEquals(Arrays.asList(
|
137
117
|
"C1,C2,C3,C4,C5,C6,C7",
|
138
|
-
"
|
139
|
-
"
|
118
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
|
119
|
+
",,,,,,"),
|
140
120
|
read("oracle-input000.00.csv"));
|
141
121
|
}
|
142
122
|
}
|
@@ -144,12 +124,12 @@ public class OracleInputPluginTest
|
|
144
124
|
@Test
|
145
125
|
public void testQueryLower() throws Exception
|
146
126
|
{
|
147
|
-
if (
|
148
|
-
|
127
|
+
if (enabled) {
|
128
|
+
test("/oracle/yml/input-query-lower.yml");
|
149
129
|
assertEquals(Arrays.asList(
|
150
130
|
"C1,C2,C3,C4,C5,C6,C7",
|
151
|
-
"
|
152
|
-
"
|
131
|
+
"-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
|
132
|
+
",,,,,,"),
|
153
133
|
read("oracle-input000.00.csv"));
|
154
134
|
}
|
155
135
|
}
|
@@ -157,12 +137,12 @@ public class OracleInputPluginTest
|
|
157
137
|
@Test
|
158
138
|
public void testColumnOptions() throws Exception
|
159
139
|
{
|
160
|
-
if (
|
161
|
-
|
140
|
+
if (enabled) {
|
141
|
+
test("/oracle/yml/input-column-options.yml");
|
162
142
|
assertEquals(Arrays.asList(
|
163
|
-
"C1,C2,C3,C4,C5,C6,C7",
|
164
|
-
"
|
165
|
-
"
|
143
|
+
"ID,C1,C2,C3,C4,C5,C6,C7",
|
144
|
+
"10,,,,,,,",
|
145
|
+
"11,-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
|
166
146
|
read("oracle-input000.00.csv"));
|
167
147
|
}
|
168
148
|
}
|
@@ -170,27 +150,20 @@ public class OracleInputPluginTest
|
|
170
150
|
@Test
|
171
151
|
public void testColumnOptionsLower() throws Exception
|
172
152
|
{
|
173
|
-
if (
|
174
|
-
|
153
|
+
if (enabled) {
|
154
|
+
test("/oracle/yml/input-column-options-lower.yml");
|
175
155
|
assertEquals(Arrays.asList(
|
176
|
-
"C1,C2,C3,C4,C5,C6,C7",
|
177
|
-
"
|
178
|
-
"
|
156
|
+
"ID,C1,C2,C3,C4,C5,C6,C7",
|
157
|
+
"10,,,,,,,",
|
158
|
+
"11,-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
|
179
159
|
read("oracle-input000.00.csv"));
|
180
160
|
}
|
181
161
|
}
|
182
162
|
|
183
|
-
|
163
|
+
@Override
|
164
|
+
protected Connection connect() throws SQLException
|
184
165
|
{
|
185
|
-
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
private String convertPath(String name) throws URISyntaxException
|
190
|
-
{
|
191
|
-
if (getClass().getResource(name) == null) {
|
192
|
-
return name;
|
193
|
-
}
|
194
|
-
return new File(getClass().getResource(name).toURI()).getAbsolutePath();
|
166
|
+
return DriverManager.getConnection(String.format(ENGLISH, "jdbc:oracle:thin:@%s:%d:%s", getHost(), getPort(), getDatabase()),
|
167
|
+
getUser(), getPassword());
|
195
168
|
}
|
196
169
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
in:
|
2
2
|
type: oracle
|
3
|
-
host:
|
4
|
-
database:
|
5
|
-
user:
|
6
|
-
password:
|
3
|
+
host: #host#
|
4
|
+
database: #database#
|
5
|
+
user: #user#
|
6
|
+
password: #password#
|
7
7
|
table: TEST1
|
8
8
|
select: "*"
|
9
|
+
order_by: "ID"
|
9
10
|
column_options:
|
10
11
|
c5: {type: string, timestamp_format: '%Y/%m/%d', timezone: "+0900"}
|
11
12
|
c6: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S', timezone: "+0900"}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
in:
|
2
2
|
type: oracle
|
3
|
-
host:
|
4
|
-
database:
|
5
|
-
user:
|
6
|
-
password:
|
3
|
+
host: #host#
|
4
|
+
database: #database#
|
5
|
+
user: #user#
|
6
|
+
password: #password#
|
7
7
|
table: TEST1
|
8
8
|
select: "*"
|
9
|
+
order_by: "ID"
|
9
10
|
column_options:
|
10
11
|
C5: {type: string, timestamp_format: '%Y/%m/%d', timezone: "+0900"}
|
11
12
|
C6: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S', timezone: "+0900"}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
in:
|
2
2
|
type: oracle
|
3
|
-
host:
|
4
|
-
database:
|
5
|
-
user:
|
6
|
-
password:
|
7
|
-
query: "select c1, c2, c3, c4, c5, c6, c7 from test1"
|
3
|
+
host: #host#
|
4
|
+
database: #database#
|
5
|
+
user: #user#
|
6
|
+
password: #password#
|
7
|
+
query: "select c1, c2, c3, c4, c5, c6, c7 from test1 order by c1"
|
8
8
|
|
9
9
|
out:
|
10
10
|
type: file
|
@@ -1,10 +1,10 @@
|
|
1
1
|
in:
|
2
2
|
type: oracle
|
3
|
-
host:
|
4
|
-
database:
|
5
|
-
user:
|
6
|
-
password:
|
7
|
-
query: "SELECT C1, C2, C3, C4, C5, C6, C7 FROM TEST1"
|
3
|
+
host: #host#
|
4
|
+
database: #database#
|
5
|
+
user: #user#
|
6
|
+
password: #password#
|
7
|
+
query: "SELECT C1, C2, C3, C4, C5, C6, C7 FROM TEST1 ORDER BY C1"
|
8
8
|
|
9
9
|
out:
|
10
10
|
type: file
|
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.
|
4
|
+
version: 0.8.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-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Selects records from a table.
|
14
14
|
email:
|
@@ -19,8 +19,8 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- README.md
|
21
21
|
- build.gradle
|
22
|
-
- classpath/embulk-input-jdbc-0.
|
23
|
-
- classpath/embulk-input-oracle-0.
|
22
|
+
- classpath/embulk-input-jdbc-0.8.0.jar
|
23
|
+
- classpath/embulk-input-oracle-0.8.0.jar
|
24
24
|
- lib/embulk/input/oracle.rb
|
25
25
|
- src/main/java/org/embulk/input/OracleInputPlugin.java
|
26
26
|
- src/main/java/org/embulk/input/oracle/OracleInputConnection.java
|