embulk-input-db2 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/build.gradle +1 -2
  3. data/classpath/{embulk-input-db2-0.8.0.jar → embulk-input-db2-0.8.1.jar} +0 -0
  4. data/classpath/embulk-input-jdbc-0.8.1.jar +0 -0
  5. data/src/test/java/org/embulk/input/db2/BasicTest.java +75 -0
  6. data/src/test/java/org/embulk/input/db2/DB2Tests.java +55 -0
  7. data/src/test/resources/org/embulk/input/db2/test/expect/basic/setup.sql +111 -0
  8. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_datetime_config.yml +3 -0
  9. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_datetime_expected.csv +2 -0
  10. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_datetime_expected.diff +2 -0
  11. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_number_config.yml +3 -0
  12. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_number_expected.csv +3 -0
  13. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_number_expected.diff +2 -0
  14. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_string_config.yml +3 -0
  15. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_string_expected.csv +2 -0
  16. data/src/test/resources/org/embulk/input/db2/test/expect/basic/test_string_expected.diff +2 -0
  17. metadata +16 -8
  18. data/classpath/embulk-input-jdbc-0.8.0.jar +0 -0
  19. data/src/test/java/org/embulk/input/db2/DB2InputPluginTest.java +0 -290
  20. data/src/test/resources/db2/yml/input-datetime.yml +0 -23
  21. data/src/test/resources/db2/yml/input-number.yml +0 -16
  22. data/src/test/resources/db2/yml/input-string.yml +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22c93dbebbe181e15af9ee5200d4ff7883ebe074
4
- data.tar.gz: 4f4636cbd2ba6fa6b05b1fcdacb82a96b5cd5fc6
3
+ metadata.gz: 06a5984b0d4a9cecdd028b112c0510b2732bf4e4
4
+ data.tar.gz: 044de0cd09805ad20b8bebccd91386a44c19d7da
5
5
  SHA512:
6
- metadata.gz: 2212f33180ac595f9ece95d990958c2a4644ee2a3e5ac27dfb6e3a379266cc7843733d0fff3c0f6769534041debfa127790bf729e475d96e196d2bd71f9d932d
7
- data.tar.gz: f7396aa5648456ef879a18129494c5d9d4ddf77dcabf3692efeef242a4045afc81f223a99e03a745e09bffcd73d0f18ce631253fd3c6cd96ac4d181ad72252aa
6
+ metadata.gz: afc2af61dbe652c1b1305ae0a96c4e9949c97c02bd2ef624c14874e2055ac8da61072e5e11db78140adb1e946dce461f79f0f1430c371f723a69d034697fc999
7
+ data.tar.gz: 20dd2d46d6b85d170a896a10b441872966d32b17c8a9aa61360c297ec31f97228bb6873ccdd508cd892896bfb1f2e69efe53b77a41a5639eff5bf86e5eed7e04
data/build.gradle CHANGED
@@ -1,7 +1,6 @@
1
1
  dependencies {
2
2
  compile project(':embulk-input-jdbc')
3
3
 
4
- testCompile project(':embulk-input-jdbc').sourceSets.test.output
5
- testCompile 'org.embulk:embulk-standards:0.8.8'
4
+ testCompile 'org.embulk:embulk-standards:0.8.15'
6
5
  testCompile files('driver/db2jcc4.jar')
7
6
  }
@@ -0,0 +1,75 @@
1
+ package org.embulk.input.db2;
2
+
3
+ import static org.embulk.input.db2.DB2Tests.execute;
4
+ import static org.embulk.test.EmbulkTests.readSortedFile;
5
+ import static org.hamcrest.Matchers.is;
6
+ import static org.junit.Assert.assertThat;
7
+
8
+ import java.nio.file.Path;
9
+
10
+ import org.embulk.config.ConfigDiff;
11
+ import org.embulk.config.ConfigSource;
12
+ import org.embulk.input.DB2InputPlugin;
13
+ import org.embulk.spi.InputPlugin;
14
+ import org.embulk.test.EmbulkTests;
15
+ import org.embulk.test.TestingEmbulk;
16
+ import org.junit.Before;
17
+ import org.junit.Rule;
18
+ import org.junit.Test;
19
+
20
+ public class BasicTest
21
+ {
22
+ private static final String BASIC_RESOURCE_PATH = "org/embulk/input/db2/test/expect/basic/";
23
+
24
+ private static ConfigSource loadYamlResource(TestingEmbulk embulk, String fileName)
25
+ {
26
+ return embulk.loadYamlResource(BASIC_RESOURCE_PATH + fileName);
27
+ }
28
+
29
+ private static String readResource(String fileName)
30
+ {
31
+ return EmbulkTests.readResource(BASIC_RESOURCE_PATH + fileName);
32
+ }
33
+
34
+ @Rule
35
+ public TestingEmbulk embulk = TestingEmbulk.builder()
36
+ .registerPlugin(InputPlugin.class, "db2", DB2InputPlugin.class)
37
+ .build();
38
+
39
+ private ConfigSource baseConfig;
40
+
41
+ @Before
42
+ public void setup() throws Exception
43
+ {
44
+ baseConfig = DB2Tests.baseConfig();
45
+ execute(BASIC_RESOURCE_PATH + "setup.sql"); // setup rows
46
+ }
47
+
48
+ @Test
49
+ public void testString() throws Exception
50
+ {
51
+ Path out1 = embulk.createTempFile("csv");
52
+ TestingEmbulk.RunResult result1 = embulk.runInput(baseConfig.merge(loadYamlResource(embulk, "test_string_config.yml")), out1);
53
+ assertThat(readSortedFile(out1), is(readResource("test_string_expected.csv")));
54
+ assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_string_expected.diff")));
55
+ }
56
+
57
+ @Test
58
+ public void testNumber() throws Exception
59
+ {
60
+ Path out1 = embulk.createTempFile("csv");
61
+ TestingEmbulk.RunResult result1 = embulk.runInput(baseConfig.merge(loadYamlResource(embulk, "test_number_config.yml")), out1);
62
+ // (double)1.23456f becomes "1.2345600128173828", not "1.23456", because of difference of precision.
63
+ assertThat(readSortedFile(out1), is(readResource("test_number_expected.csv")));
64
+ assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_number_expected.diff")));
65
+ }
66
+
67
+ @Test
68
+ public void testDatetime() throws Exception
69
+ {
70
+ Path out1 = embulk.createTempFile("csv");
71
+ TestingEmbulk.RunResult result1 = embulk.runInput(baseConfig.merge(loadYamlResource(embulk, "test_datetime_config.yml")), out1);
72
+ assertThat(readSortedFile(out1), is(readResource("test_datetime_expected.csv")));
73
+ assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_datetime_expected.diff")));
74
+ }
75
+ }
@@ -0,0 +1,55 @@
1
+ package org.embulk.input.db2;
2
+
3
+ import static java.util.Locale.ENGLISH;
4
+
5
+ import java.io.File;
6
+ import java.io.IOException;
7
+ import java.net.URL;
8
+
9
+ import org.embulk.config.ConfigSource;
10
+ import org.embulk.test.EmbulkTests;
11
+
12
+ import com.google.common.base.Throwables;
13
+ import com.google.common.io.ByteStreams;
14
+
15
+ public class DB2Tests
16
+ {
17
+ public static ConfigSource baseConfig()
18
+ {
19
+ return EmbulkTests.config("EMBULK_INPUT_DB2_TEST_CONFIG");
20
+ }
21
+
22
+ public static void execute(String sqlName) throws Exception
23
+ {
24
+ // DB2Tests.excute takes a resource name of SQL file, doesn't take a SQL sentence as other XXXTests do.
25
+ // Because TestingEmbulk.createTempFile might create a file whose name contains ' ' and DB2 clpplus cannot read such a file.
26
+ // But if root directory name of embulk-input-db2 contains ' ', tests will fail for the same reason.
27
+ URL sqlRrl = DB2Tests.class.getResource("/" + sqlName);
28
+
29
+ ConfigSource config = baseConfig();
30
+ String host = config.get(String.class, "host");
31
+ String port = config.get(String.class, "port", "50000");
32
+ String user = config.get(String.class, "user");
33
+ String password = config.get(String.class, "password");
34
+ String database = config.get(String.class, "database");
35
+
36
+ boolean isWindows = File.separatorChar == '\\';
37
+ ProcessBuilder pb = new ProcessBuilder(
38
+ "clpplus." + (isWindows ? "bat" : "sh"),
39
+ user + "/" + password + "@" + host + ":" + port + "/" + database,
40
+ "@" + new File(sqlRrl.toURI()).getAbsolutePath());
41
+ pb.redirectErrorStream(true);
42
+ int code;
43
+ try {
44
+ Process process = pb.start();
45
+ ByteStreams.copy(process.getInputStream(), System.out);
46
+ code = process.waitFor();
47
+ } catch (IOException | InterruptedException ex) {
48
+ throw Throwables.propagate(ex);
49
+ }
50
+ if (code != 0) {
51
+ throw new RuntimeException(String.format(ENGLISH,
52
+ "Command finished with non-zero exit code. Exit code is %d.", code));
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,111 @@
1
+ DROP TABLE TEST_STRING;
2
+
3
+ CREATE TABLE TEST_STRING (
4
+ ID CHAR(2) NOT NULL,
5
+ CHAR_ITEM CHAR(4),
6
+ VARCHAR_ITEM VARCHAR(8),
7
+ CLOB_ITEM CLOB,
8
+ GRAPHIC_ITEM GRAPHIC(4),
9
+ VARGRAPHIC_ITEM VARGRAPHIC(8),
10
+ NCHAR_ITEM NCHAR(4),
11
+ NVARCHAR_ITEM NVARCHAR(8),
12
+ NCLOB_ITEM NCLOB,
13
+ PRIMARY KEY (ID));
14
+
15
+ INSERT INTO TEST_STRING VALUES(
16
+ '10',
17
+ NULL,
18
+ NULL,
19
+ NULL,
20
+ NULL,
21
+ NULL,
22
+ NULL,
23
+ NULL,
24
+ NULL);
25
+
26
+ INSERT INTO TEST_STRING VALUES(
27
+ '11',
28
+ 'aa',
29
+ 'AA',
30
+ 'aaaaaaaaaaaa',
31
+ 'ああ',
32
+ 'いいいい',
33
+ 'aa',
34
+ 'AA',
35
+ 'aaaaaaaa');
36
+
37
+ DROP TABLE TEST_NUMBER;
38
+
39
+ CREATE TABLE TEST_NUMBER (
40
+ ID CHAR(2) NOT NULL,
41
+ SMALLINT_ITEM SMALLINT,
42
+ INTEGER_ITEM INTEGER,
43
+ BIGINT_ITEM BIGINT,
44
+ DECIMAL_ITEM DECIMAL(8,2),
45
+ NUMERIC_ITEM NUMERIC(8,2),
46
+ REAL_ITEM REAL,
47
+ DOUBLE_ITEM DOUBLE,
48
+ FLOAT_ITEM FLOAT,
49
+ PRIMARY KEY (ID));
50
+
51
+ INSERT INTO TEST_NUMBER VALUES(
52
+ '10',
53
+ NULL,
54
+ NULL,
55
+ NULL,
56
+ NULL,
57
+ NULL,
58
+ NULL,
59
+ NULL,
60
+ NULL);
61
+
62
+ INSERT INTO TEST_NUMBER VALUES(
63
+ '11',
64
+ 12345,
65
+ 123456789,
66
+ 123456789012,
67
+ 123456.78,
68
+ 876543.21,
69
+ 1.23456,
70
+ 1.23456789012,
71
+ 3.45678901234);
72
+
73
+ INSERT INTO TEST_NUMBER VALUES(
74
+ '12',
75
+ -12345,
76
+ -123456789,
77
+ -123456789012,
78
+ -123456.78,
79
+ -876543.21,
80
+ -1.23456,
81
+ -1.23456789012,
82
+ -3.45678901234);
83
+
84
+ DROP TABLE TEST_DATETIME;
85
+
86
+ CREATE TABLE TEST_DATETIME (
87
+ ID CHAR(2) NOT NULL,
88
+ DATE_ITEM DATE,
89
+ TIME_ITEM TIME,
90
+ TIMESTAMP_ITEM TIMESTAMP,
91
+ TIMESTAMP0_ITEM TIMESTAMP(0),
92
+ TIMESTAMP12_ITEM TIMESTAMP(12),
93
+ PRIMARY KEY (ID));
94
+
95
+ INSERT INTO TEST_DATETIME VALUES(
96
+ '10',
97
+ NULL,
98
+ NULL,
99
+ NULL,
100
+ NULL,
101
+ NULL);
102
+
103
+ INSERT INTO TEST_DATETIME VALUES(
104
+ '11',
105
+ TO_TIMESTAMP('2016-09-08', 'YYYY-MM-DD'),
106
+ TO_TIMESTAMP('12:34:45', 'HH24:MI:SS'),
107
+ TO_TIMESTAMP('2016-09-09 12:34:45.123456', 'YYYY-MM-DD HH24:MI:SS.FF6'),
108
+ TO_TIMESTAMP('2016-09-10 12:34:45', 'YYYY-MM-DD HH24:MI:SS'),
109
+ TO_TIMESTAMP('2016-09-11 12:34:45.123456789012', 'YYYY-MM-DD HH24:MI:SS.FF12'));
110
+
111
+ EXIT;
@@ -0,0 +1,3 @@
1
+ table: TEST_DATETIME
2
+ select: "*"
3
+ order_by: "id"
@@ -0,0 +1,2 @@
1
+ 10,,,,,
2
+ 11,2016-09-07 21:00:00.000000 +0000,1970-01-01 10:34:45.000000 +0000,2016-09-09 09:34:45.123456 +0000,2016-09-10 09:34:45.000000 +0000,2016-09-11 09:34:45.123456 +0000
@@ -0,0 +1,3 @@
1
+ table: TEST_NUMBER
2
+ select: "*"
3
+ order_by: "id"
@@ -0,0 +1,3 @@
1
+ 10,,,,,,,,
2
+ 11,12345,123456789,123456789012,123456.78,876543.21,1.2345600128173828,1.23456789012,3.45678901234
3
+ 12,-12345,-123456789,-123456789012,-123456.78,-876543.21,-1.2345600128173828,-1.23456789012,-3.45678901234
@@ -0,0 +1,3 @@
1
+ table: TEST_STRING
2
+ select: "*"
3
+ order_by: "id"
@@ -0,0 +1,2 @@
1
+ 10,,,,,,,,
2
+ 11,aa ,AA,aaaaaaaaaaaa,ああ ,いいいい,aa ,AA,aaaaaaaa
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-db2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
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-10-13 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selects records from a table.
14
14
  email:
@@ -19,15 +19,23 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - README.md
21
21
  - build.gradle
22
- - classpath/embulk-input-db2-0.8.0.jar
23
- - classpath/embulk-input-jdbc-0.8.0.jar
22
+ - classpath/embulk-input-db2-0.8.1.jar
23
+ - classpath/embulk-input-jdbc-0.8.1.jar
24
24
  - lib/embulk/input/db2.rb
25
25
  - src/main/java/org/embulk/input/DB2InputPlugin.java
26
26
  - src/main/java/org/embulk/input/db2/DB2InputConnection.java
27
- - src/test/java/org/embulk/input/db2/DB2InputPluginTest.java
28
- - src/test/resources/db2/yml/input-datetime.yml
29
- - src/test/resources/db2/yml/input-number.yml
30
- - src/test/resources/db2/yml/input-string.yml
27
+ - src/test/java/org/embulk/input/db2/BasicTest.java
28
+ - src/test/java/org/embulk/input/db2/DB2Tests.java
29
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/setup.sql
30
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_datetime_config.yml
31
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_datetime_expected.csv
32
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_datetime_expected.diff
33
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_number_config.yml
34
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_number_expected.csv
35
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_number_expected.diff
36
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_string_config.yml
37
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_string_expected.csv
38
+ - src/test/resources/org/embulk/input/db2/test/expect/basic/test_string_expected.diff
31
39
  homepage: https://github.com/embulk/embulk-input-jdbc
32
40
  licenses:
33
41
  - Apache 2.0
Binary file
@@ -1,290 +0,0 @@
1
- package org.embulk.input.db2;
2
-
3
- import static java.util.Locale.ENGLISH;
4
- import static org.junit.Assert.assertEquals;
5
-
6
- import java.sql.Connection;
7
- import java.sql.DriverManager;
8
- import java.sql.SQLException;
9
- import java.util.Arrays;
10
-
11
- import org.embulk.input.AbstractJdbcInputPluginTest;
12
- import org.embulk.input.DB2InputPlugin;
13
- import org.embulk.spi.InputPlugin;
14
- import org.junit.Test;
15
-
16
- public class DB2InputPluginTest extends AbstractJdbcInputPluginTest
17
- {
18
- @Override
19
- protected void prepare() throws SQLException
20
- {
21
- tester.addPlugin(InputPlugin.class, "db2", DB2InputPlugin.class);
22
-
23
- try {
24
- Class.forName("com.ibm.db2.jcc.DB2Driver");
25
- } catch (ClassNotFoundException e) {
26
- System.err.println("Warning: you should put 'db2jcc4.jar' in 'embulk-input-db2/driver' directory in order to test.");
27
- return;
28
- }
29
-
30
- try {
31
- connect();
32
- } catch (SQLException e) {
33
- System.err.println(e);
34
- System.err.println(String.format(ENGLISH, "Warning: prepare a schema on DB2 (server = %s, port = %d, database = %s, user = %s, password = %s).",
35
- getHost(), getPort(), getDatabase(), getUser(), getPassword()));
36
- return;
37
- }
38
-
39
- enabled = true;
40
-
41
- String dropString = "DROP TABLE TEST_STRING";
42
- executeSQL(dropString, true);
43
-
44
- String createString =
45
- "CREATE TABLE TEST_STRING ("
46
- + "ID CHAR(2) NOT NULL,"
47
- + "CHAR_ITEM CHAR(4),"
48
- + "VARCHAR_ITEM VARCHAR(8),"
49
- + "CLOB_ITEM CLOB,"
50
- + "GRAPHIC_ITEM GRAPHIC(4),"
51
- + "VARGRAPHIC_ITEM VARGRAPHIC(8),"
52
- + "NCHAR_ITEM NCHAR(4),"
53
- + "NVARCHAR_ITEM NVARCHAR(8),"
54
- + "NCLOB_ITEM NCLOB,"
55
- + "PRIMARY KEY (ID))";
56
- executeSQL(createString);
57
-
58
- String insertString1 =
59
- "INSERT INTO TEST_STRING VALUES("
60
- + "'10',"
61
- + "NULL,"
62
- + "NULL,"
63
- + "NULL,"
64
- + "NULL,"
65
- + "NULL,"
66
- + "NULL,"
67
- + "NULL,"
68
- + "NULL)";
69
- executeSQL(insertString1);
70
-
71
- String insertString2 =
72
- "INSERT INTO TEST_STRING VALUES("
73
- + "'11',"
74
- + "'aa',"
75
- + "'AA',"
76
- + "'aaaaaaaaaaaa',"
77
- + "'ああ',"
78
- + "'いいいい',"
79
- + "'aa',"
80
- + "'AA',"
81
- + "'aaaaaaaa')";
82
- executeSQL(insertString2);
83
-
84
- String dropNumber = "DROP TABLE TEST_NUMBER";
85
- executeSQL(dropNumber, true);
86
-
87
- String createNumber =
88
- "CREATE TABLE TEST_NUMBER ("
89
- + "ID CHAR(2) NOT NULL,"
90
- + "SMALLINT_ITEM SMALLINT,"
91
- + "INTEGER_ITEM INTEGER,"
92
- + "BIGINT_ITEM BIGINT,"
93
- + "DECIMAL_ITEM DECIMAL(8,2),"
94
- + "NUMERIC_ITEM NUMERIC(8,2),"
95
- + "REAL_ITEM REAL,"
96
- + "DOUBLE_ITEM DOUBLE,"
97
- + "FLOAT_ITEM FLOAT,"
98
- + "PRIMARY KEY (ID))";
99
- executeSQL(createNumber);
100
-
101
- String insertNumber1 =
102
- "INSERT INTO TEST_NUMBER VALUES("
103
- + "'10',"
104
- + "NULL,"
105
- + "NULL,"
106
- + "NULL,"
107
- + "NULL,"
108
- + "NULL,"
109
- + "NULL,"
110
- + "NULL,"
111
- + "NULL)";
112
- executeSQL(insertNumber1);
113
-
114
- String insertNumber2 =
115
- "INSERT INTO TEST_NUMBER VALUES("
116
- + "'11',"
117
- + "12345,"
118
- + "123456789,"
119
- + "123456789012,"
120
- + "123456.78,"
121
- + "876543.21,"
122
- + "1.23456,"
123
- + "1.23456789012,"
124
- + "3.45678901234)";
125
- executeSQL(insertNumber2);
126
-
127
- String insertNumber3 =
128
- "INSERT INTO TEST_NUMBER VALUES("
129
- + "'12',"
130
- + "-12345,"
131
- + "-123456789,"
132
- + "-123456789012,"
133
- + "-123456.78,"
134
- + "-876543.21,"
135
- + "-1.23456,"
136
- + "-1.23456789012,"
137
- + "-3.45678901234)";
138
- executeSQL(insertNumber3);
139
-
140
- String dropDateTime = "DROP TABLE TEST_DATETIME";
141
- executeSQL(dropDateTime, true);
142
-
143
- String createDateTime =
144
- "CREATE TABLE TEST_DATETIME ("
145
- + "ID CHAR(2) NOT NULL,"
146
- + "DATE_ITEM DATE,"
147
- + "TIME_ITEM TIME,"
148
- + "TIMESTAMP_ITEM TIMESTAMP,"
149
- + "TIMESTAMP0_ITEM TIMESTAMP(0),"
150
- + "TIMESTAMP12_ITEM TIMESTAMP(12),"
151
- + "PRIMARY KEY (ID))";
152
- executeSQL(createDateTime);
153
-
154
- String insertDateTime1 =
155
- "INSERT INTO TEST_DATETIME VALUES("
156
- + "'10',"
157
- + "NULL,"
158
- + "NULL,"
159
- + "NULL,"
160
- + "NULL,"
161
- + "NULL)";
162
- executeSQL(insertDateTime1);
163
-
164
- String insertDateTime2 =
165
- "INSERT INTO TEST_DATETIME VALUES("
166
- + "'11',"
167
- + "'2016-09-08',"
168
- + "'12:34:45',"
169
- + "'2016-09-09 12:34:45.123456',"
170
- + "'2016-09-10 12:34:45',"
171
- + "'2016-09-11 12:34:45.123456789012')";
172
- executeSQL(insertDateTime2);
173
-
174
- /*
175
- String create1 =
176
- "create table test1 ("
177
- + "c1 tinyint,"
178
- + "c2 smallint,"
179
- + "c3 int,"
180
- + "c4 bigint,"
181
- + "c5 float,"
182
- + "c6 double,"
183
- + "c7 decimal(4,0),"
184
- + "c8 decimal(20,2),"
185
- + "c9 char(4),"
186
- + "c10 varchar(4),"
187
- + "c11 date,"
188
- + "c12 datetime,"
189
- + "c13 timestamp,"
190
- + "c14 time,"
191
- + "c15 datetime(6));";
192
- executeSQL(create1);
193
-
194
- String insert1 =
195
- "insert into test1 values("
196
- + "null,"
197
- + "null,"
198
- + "null,"
199
- + "null,"
200
- + "null,"
201
- + "null,"
202
- + "null,"
203
- + "null,"
204
- + "null,"
205
- + "null,"
206
- + "null,"
207
- + "null,"
208
- + "'2015-06-04 23:45:06',"
209
- + "null,"
210
- + "null);";
211
- executeSQL(insert1);
212
-
213
- String insert2 =
214
- "insert into test1 values("
215
- + "99,"
216
- + "9999,"
217
- + "-99999999,"
218
- + "-9999999999999999,"
219
- + "1.2345,"
220
- + "1.234567890123,"
221
- + "-1234,"
222
- + "123456789012345678.12,"
223
- + "'5678',"
224
- + "'xy',"
225
- + "'2015-06-04',"
226
- + "'2015-06-04 12:34:56',"
227
- + "'2015-06-04 23:45:06',"
228
- + "'08:04:02',"
229
- + "'2015-06-04 01:02:03.123456');";
230
- executeSQL(insert2);
231
-
232
- String drop2 = "drop table if exists test2";
233
- executeSQL(drop2);
234
-
235
- String create2 = "create table test2 (c1 bigint unsigned);";
236
- executeSQL(create2);
237
-
238
- String insert3 = "insert into test2 values(18446744073709551615)";
239
- executeSQL(insert3);*/
240
- }
241
-
242
- @Test
243
- public void testString() throws Exception
244
- {
245
- if (enabled) {
246
- test("/db2/yml/input-string.yml");
247
- assertEquals(Arrays.asList(
248
- "ID,CHAR_ITEM,VARCHAR_ITEM,CLOB_ITEM,GRAPHIC_ITEM,VARGRAPHIC_ITEM,NCHAR_ITEM,NVARCHAR_ITEM,NCLOB_ITEM",
249
- "10,,,,,,,,",
250
- "11,aa ,AA,aaaaaaaaaaaa,ああ ,いいいい,aa ,AA,aaaaaaaa"),
251
- read("db2-input000.00.csv"));
252
- }
253
- }
254
-
255
- @Test
256
- public void testNumber() throws Exception
257
- {
258
- if (enabled) {
259
- test("/db2/yml/input-number.yml");
260
- assertEquals(Arrays.asList(
261
- "ID,SMALLINT_ITEM,INTEGER_ITEM,BIGINT_ITEM,DECIMAL_ITEM,NUMERIC_ITEM,REAL_ITEM,DOUBLE_ITEM,FLOAT_ITEM",
262
- "10,,,,,,,,",
263
- // (double)1.23456f becomes "1.2345600128173828", not "1.23456", because of difference of precision.
264
- "11,12345,123456789,123456789012,123456.78,876543.21," + (double)1.23456f + ",1.23456789012,3.45678901234",
265
- "12,-12345,-123456789,-123456789012,-123456.78,-876543.21," + (double)-1.23456f + ",-1.23456789012,-3.45678901234"),
266
- read("db2-input000.00.csv"));
267
- }
268
- }
269
-
270
- @Test
271
- public void testDateTime() throws Exception
272
- {
273
- if (enabled) {
274
- test("/db2/yml/input-datetime.yml");
275
- assertEquals(Arrays.asList(
276
- "ID,DATE_ITEM,TIME_ITEM,TIMESTAMP_ITEM,TIMESTAMP0_ITEM,TIMESTAMP12_ITEM",
277
- "10,,,,,",
278
- // precision of embulk timestamp is nano seconds
279
- "11,2016/09/07,03-34-45,2016/09/09 03:34:45,2016/09/10 12:34:45,2016/09/11 03:34:45.123456789000"),
280
- read("db2-input000.00.csv"));
281
- }
282
- }
283
-
284
- @Override
285
- protected Connection connect() throws SQLException
286
- {
287
- return DriverManager.getConnection(String.format(ENGLISH, "jdbc:db2://%s:%d/%s", getHost(), getPort(), getDatabase()),
288
- getUser(), getPassword());
289
- }
290
- }
@@ -1,23 +0,0 @@
1
- in:
2
- type: db2
3
- host: #host#
4
- database: #database#
5
- user: #user#
6
- password: #password#
7
- table: TEST_DATETIME
8
- select: "*"
9
- order_by: "id"
10
- default_timezone: '+0900'
11
-
12
- out:
13
- type: file
14
- path_prefix: db2-input
15
- file_ext: csv
16
- formatter:
17
- type: csv
18
- column_options:
19
- DATE_ITEM: {format: '%Y/%m/%d'}
20
- TIME_ITEM: {format: '%H-%M-%S'}
21
- TIMESTAMP_ITEM: {format: '%Y/%m/%d %H:%M:%S'}
22
- TIMESTAMP0_ITEM: {format: '%Y/%m/%d %H:%M:%S', timezone: '+0900'}
23
- TIMESTAMP12_ITEM: {format: '%Y/%m/%d %H:%M:%S.%12N'}
@@ -1,16 +0,0 @@
1
- in:
2
- type: db2
3
- host: #host#
4
- database: #database#
5
- user: #user#
6
- password: #password#
7
- table: TEST_NUMBER
8
- select: "*"
9
- order_by: "id"
10
-
11
- out:
12
- type: file
13
- path_prefix: db2-input
14
- file_ext: csv
15
- formatter:
16
- type: csv
@@ -1,16 +0,0 @@
1
- in:
2
- type: db2
3
- host: #host#
4
- database: #database#
5
- user: #user#
6
- password: #password#
7
- table: TEST_STRING
8
- select: "*"
9
- order_by: "id"
10
-
11
- out:
12
- type: file
13
- path_prefix: db2-input
14
- file_ext: csv
15
- formatter:
16
- type: csv