embulk-output-sqlserver 0.7.12 → 0.7.13
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 +2 -0
- data/build.gradle +1 -1
- data/classpath/embulk-output-jdbc-0.7.13.jar +0 -0
- data/classpath/embulk-output-sqlserver-0.7.13.jar +0 -0
- data/src/main/java/org/embulk/output/SQLServerOutputPlugin.java +1 -1
- data/src/main/java/org/embulk/output/sqlserver/NativeBatchInsert.java +1 -1
- data/src/main/java/org/embulk/output/sqlserver/SQLServerOutputConnection.java +2 -21
- data/src/main/java/org/embulk/output/sqlserver/nativeclient/NativeClientWrapper.java +32 -2
- data/src/test/java/org/embulk/output/sqlserver/NativeTest.java +258 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/setup.sql +160 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bigint_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bit_null.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bit_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bit_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_char_null.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_char_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_char_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_date_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_date_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime2_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime2_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_decimal_null.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_decimal_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_decimal_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_float_null.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_float_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_float_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_int_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_integer_null.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_integer_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_money_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_nchar_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_ntext_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_numeric_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_nvarchar_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_real_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smalldatetime_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smalldatetime_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smallint_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smallmoney_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_text_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_time_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_time_null_expected.csv +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_timestamp_null.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_tinyint_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_varchar_null.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_varchar_null.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_varchar_null_expected.csv +2 -0
- metadata +46 -4
- data/classpath/embulk-output-jdbc-0.7.12.jar +0 -0
- data/classpath/embulk-output-sqlserver-0.7.12.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: 86ee70f432bde93e86ca7096607661cec4cf99f7
|
|
4
|
+
data.tar.gz: 810aabc28c4b36d448a22be742b5cf2b8e78b80f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec2e66e980bb6d6c825b6389ffde4b2bb0325939fd59b7914dab15542fc1f81446c4a0ce4cd86d9e161b0cba9940eb8863ea2d35ba00cd32cbd0e7a0438df3dc
|
|
7
|
+
data.tar.gz: 36ec5540ea9df552fc626ec3849c2cea7fe9b6e967ed60e028e6b073e46a32d763c87f50c698aef0f2d46b99f160d0d87aa3c512341f11c7ae829c0fd01ecc5d
|
data/README.md
CHANGED
|
@@ -26,6 +26,8 @@ embulk "-J-Djava.library.path=C:\drivers" run input-sqlserver.yml
|
|
|
26
26
|
- **temp_schema**: schema name for intermediate tables. by default, intermediate tables will be created in the same schema as destination table. (string, optional)
|
|
27
27
|
- **url**: URL of the JDBC connection (string, optional)
|
|
28
28
|
- **table**: destination table name (string, required)
|
|
29
|
+
- **create_table_constraint** table constraint added to `CREATE TABLE` statement, like `CREATE TABLE <table_name> (<column1> <type1>, <column2> <type2>, ..., <create_table_constraint>) <create_table_option>`.
|
|
30
|
+
- **create_table_option** table option added to `CREATE TABLE` statement, like `CREATE TABLE <table_name> (<column1> <type1>, <column2> <type2>, ..., <create_table_constraint>) <create_table_option>`.
|
|
29
31
|
- **options**: extra connection properties (hash, default: {})
|
|
30
32
|
- **retry_limit** max retry count for database operations (integer, default: 12)
|
|
31
33
|
- **retry_wait** initial retry wait time in milliseconds (integer, default: 1000 (1 second))
|
data/build.gradle
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -136,7 +136,7 @@ public class SQLServerOutputPlugin
|
|
|
136
136
|
boolean useJtdsDriver = false;
|
|
137
137
|
|
|
138
138
|
if (sqlServerTask.getDriverPath().isPresent()) {
|
|
139
|
-
|
|
139
|
+
addDriverJarToClasspath(sqlServerTask.getDriverPath().get());
|
|
140
140
|
try {
|
|
141
141
|
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
|
142
142
|
} catch (Exception e) {
|
|
@@ -122,7 +122,7 @@ public class NativeBatchInsert implements BatchInsert
|
|
|
122
122
|
@Override
|
|
123
123
|
public void setNull(int sqlType) throws IOException, SQLException
|
|
124
124
|
{
|
|
125
|
-
batchWeight += client.bindNull(nextColumnIndex());
|
|
125
|
+
batchWeight += client.bindNull(nextColumnIndex(), sqlType);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
@Override
|
|
@@ -2,7 +2,6 @@ package org.embulk.output.sqlserver;
|
|
|
2
2
|
|
|
3
3
|
import java.sql.Connection;
|
|
4
4
|
import java.sql.SQLException;
|
|
5
|
-
import java.sql.Statement;
|
|
6
5
|
import java.util.Arrays;
|
|
7
6
|
import java.util.List;
|
|
8
7
|
|
|
@@ -61,27 +60,9 @@ public class SQLServerOutputConnection
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
@Override
|
|
64
|
-
|
|
63
|
+
protected boolean supportsTableIfExistsClause()
|
|
65
64
|
{
|
|
66
|
-
|
|
67
|
-
dropTable(table);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Override
|
|
72
|
-
protected void dropTableIfExists(Statement stmt, TableIdentifier table) throws SQLException
|
|
73
|
-
{
|
|
74
|
-
if (tableExists(table)) {
|
|
75
|
-
dropTable(stmt, table);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@Override
|
|
80
|
-
public void createTableIfNotExists(TableIdentifier table, JdbcSchema schema) throws SQLException
|
|
81
|
-
{
|
|
82
|
-
if (!tableExists(table)) {
|
|
83
|
-
createTable(table, schema);
|
|
84
|
-
}
|
|
65
|
+
return false;
|
|
85
66
|
}
|
|
86
67
|
|
|
87
68
|
private static final String[] SIMPLE_TYPE_NAMES = {
|
|
@@ -4,6 +4,7 @@ import java.nio.ByteBuffer;
|
|
|
4
4
|
import java.nio.CharBuffer;
|
|
5
5
|
import java.nio.charset.Charset;
|
|
6
6
|
import java.sql.SQLException;
|
|
7
|
+
import java.sql.Types;
|
|
7
8
|
import java.util.HashMap;
|
|
8
9
|
import java.util.Map;
|
|
9
10
|
|
|
@@ -150,7 +151,7 @@ public class NativeClientWrapper
|
|
|
150
151
|
NativeClient.DB_IN));
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
public int bindNull(int columnIndex) throws SQLException
|
|
154
|
+
public int bindNull(int columnIndex, int sqlType) throws SQLException
|
|
154
155
|
{
|
|
155
156
|
Pointer pointer = prepareBuffer(columnIndex, 0);
|
|
156
157
|
checkBCPResult("bcp_bind", client.bcp_bind(
|
|
@@ -160,11 +161,40 @@ public class NativeClientWrapper
|
|
|
160
161
|
NativeClient.SQL_NULL_DATA,
|
|
161
162
|
null,
|
|
162
163
|
0,
|
|
163
|
-
|
|
164
|
+
jdbcTypeToNativeClientType(sqlType),
|
|
164
165
|
columnIndex));
|
|
165
166
|
return (int)pointer.size();
|
|
166
167
|
}
|
|
167
168
|
|
|
169
|
+
private int jdbcTypeToNativeClientType(int sqlType)
|
|
170
|
+
{
|
|
171
|
+
switch (sqlType) {
|
|
172
|
+
case Types.BIT:
|
|
173
|
+
case Types.BOOLEAN:
|
|
174
|
+
return NativeClient.SQLBIT;
|
|
175
|
+
|
|
176
|
+
case Types.TINYINT: // SQL Server TINYINT needs 2 bytes because it is unsigned.
|
|
177
|
+
case Types.SMALLINT:
|
|
178
|
+
return NativeClient.SQLINT2;
|
|
179
|
+
|
|
180
|
+
case Types.INTEGER:
|
|
181
|
+
return NativeClient.SQLINT4;
|
|
182
|
+
|
|
183
|
+
case Types.BIGINT:
|
|
184
|
+
return NativeClient.SQLINT8;
|
|
185
|
+
|
|
186
|
+
case Types.REAL:
|
|
187
|
+
return NativeClient.SQLFLT4;
|
|
188
|
+
|
|
189
|
+
case Types.FLOAT:
|
|
190
|
+
case Types.DOUBLE:
|
|
191
|
+
return NativeClient.SQLFLT8;
|
|
192
|
+
|
|
193
|
+
default:
|
|
194
|
+
return NativeClient.SQLCHARACTER;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
168
198
|
public int bindValue(int columnIndex, String value) throws SQLException
|
|
169
199
|
{
|
|
170
200
|
ByteBuffer bytes = charset.encode(value);
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
package org.embulk.output.sqlserver;
|
|
2
|
+
|
|
3
|
+
import static org.embulk.output.sqlserver.SQLServerTests.execute;
|
|
4
|
+
import static org.embulk.output.sqlserver.SQLServerTests.selectRecords;
|
|
5
|
+
import static org.hamcrest.Matchers.is;
|
|
6
|
+
import static org.junit.Assert.assertThat;
|
|
7
|
+
|
|
8
|
+
import java.io.File;
|
|
9
|
+
import java.net.URISyntaxException;
|
|
10
|
+
import java.net.URL;
|
|
11
|
+
import java.nio.file.FileSystems;
|
|
12
|
+
import java.nio.file.Path;
|
|
13
|
+
|
|
14
|
+
import org.embulk.config.ConfigDiff;
|
|
15
|
+
import org.embulk.config.ConfigSource;
|
|
16
|
+
import org.embulk.output.SQLServerOutputPlugin;
|
|
17
|
+
import org.embulk.spi.OutputPlugin;
|
|
18
|
+
import org.embulk.test.EmbulkTests;
|
|
19
|
+
import org.embulk.test.TestingEmbulk;
|
|
20
|
+
import org.junit.Before;
|
|
21
|
+
import org.junit.Rule;
|
|
22
|
+
import org.junit.Test;
|
|
23
|
+
|
|
24
|
+
import com.google.common.io.Resources;
|
|
25
|
+
|
|
26
|
+
public class NativeTest
|
|
27
|
+
{
|
|
28
|
+
private static final String BASIC_RESOURCE_PATH = "org/embulk/output/sqlserver/test/expect/native/";
|
|
29
|
+
|
|
30
|
+
private static ConfigSource loadYamlResource(TestingEmbulk embulk, String fileName)
|
|
31
|
+
{
|
|
32
|
+
return embulk.loadYamlResource(BASIC_RESOURCE_PATH + fileName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private static String readResource(String fileName)
|
|
36
|
+
{
|
|
37
|
+
return EmbulkTests.readResource(BASIC_RESOURCE_PATH + fileName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Rule
|
|
41
|
+
public TestingEmbulk embulk = TestingEmbulk.builder()
|
|
42
|
+
.registerPlugin(OutputPlugin.class, "sqlserver", SQLServerOutputPlugin.class)
|
|
43
|
+
.build();
|
|
44
|
+
|
|
45
|
+
private ConfigSource baseConfig;
|
|
46
|
+
|
|
47
|
+
@Before
|
|
48
|
+
public void setup()
|
|
49
|
+
{
|
|
50
|
+
baseConfig = SQLServerTests.baseConfig();
|
|
51
|
+
execute(readResource("setup.sql")); // setup rows
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Test
|
|
55
|
+
public void testTinyIntNull() throws Exception
|
|
56
|
+
{
|
|
57
|
+
Path in1 = toPath("test_integer_null.csv");
|
|
58
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_tinyint_null.yml")), in1);
|
|
59
|
+
assertThat(selectRecords(embulk, "TEST_TINYINT"), is(readResource("test_integer_null_expected.csv")));
|
|
60
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Test
|
|
64
|
+
public void testSmallIntNull() throws Exception
|
|
65
|
+
{
|
|
66
|
+
Path in1 = toPath("test_integer_null.csv");
|
|
67
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_smallint_null.yml")), in1);
|
|
68
|
+
assertThat(selectRecords(embulk, "TEST_SMALLINT"), is(readResource("test_integer_null_expected.csv")));
|
|
69
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Test
|
|
73
|
+
public void testIntNull() throws Exception
|
|
74
|
+
{
|
|
75
|
+
Path in1 = toPath("test_integer_null.csv");
|
|
76
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_int_null.yml")), in1);
|
|
77
|
+
assertThat(selectRecords(embulk, "TEST_INT"), is(readResource("test_integer_null_expected.csv")));
|
|
78
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Test
|
|
82
|
+
public void testBigIntNull() throws Exception
|
|
83
|
+
{
|
|
84
|
+
Path in1 = toPath("test_integer_null.csv");
|
|
85
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_bigint_null.yml")), in1);
|
|
86
|
+
assertThat(selectRecords(embulk, "TEST_BIGINT"), is(readResource("test_integer_null_expected.csv")));
|
|
87
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Test
|
|
91
|
+
public void testDecimalNull() throws Exception
|
|
92
|
+
{
|
|
93
|
+
Path in1 = toPath("test_decimal_null.csv");
|
|
94
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_decimal_null.yml")), in1);
|
|
95
|
+
assertThat(selectRecords(embulk, "TEST_DECIMAL"), is(readResource("test_decimal_null_expected.csv")));
|
|
96
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Test
|
|
100
|
+
public void testNumericNull() throws Exception
|
|
101
|
+
{
|
|
102
|
+
Path in1 = toPath("test_decimal_null.csv");
|
|
103
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_numeric_null.yml")), in1);
|
|
104
|
+
assertThat(selectRecords(embulk, "TEST_NUMERIC"), is(readResource("test_decimal_null_expected.csv")));
|
|
105
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@Test
|
|
109
|
+
public void testMoneyNull() throws Exception
|
|
110
|
+
{
|
|
111
|
+
Path in1 = toPath("test_decimal_null.csv");
|
|
112
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_money_null.yml")), in1);
|
|
113
|
+
assertThat(selectRecords(embulk, "TEST_MONEY"), is(readResource("test_decimal_null_expected.csv")));
|
|
114
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Test
|
|
118
|
+
public void testSmallMoneyNull() throws Exception
|
|
119
|
+
{
|
|
120
|
+
Path in1 = toPath("test_decimal_null.csv");
|
|
121
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_smallmoney_null.yml")), in1);
|
|
122
|
+
assertThat(selectRecords(embulk, "TEST_SMALLMONEY"), is(readResource("test_decimal_null_expected.csv")));
|
|
123
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@Test
|
|
127
|
+
public void testBitNull() throws Exception
|
|
128
|
+
{
|
|
129
|
+
Path in1 = toPath("test_bit_null.csv");
|
|
130
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_bit_null.yml")), in1);
|
|
131
|
+
assertThat(selectRecords(embulk, "TEST_BIT"), is(readResource("test_bit_null_expected.csv")));
|
|
132
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Test
|
|
136
|
+
public void testRealNull() throws Exception
|
|
137
|
+
{
|
|
138
|
+
Path in1 = toPath("test_float_null.csv");
|
|
139
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_real_null.yml")), in1);
|
|
140
|
+
assertThat(selectRecords(embulk, "TEST_REAL"), is(readResource("test_float_null_expected.csv")));
|
|
141
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@Test
|
|
145
|
+
public void testFloatNull() throws Exception
|
|
146
|
+
{
|
|
147
|
+
Path in1 = toPath("test_float_null.csv");
|
|
148
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_float_null.yml")), in1);
|
|
149
|
+
assertThat(selectRecords(embulk, "TEST_FLOAT"), is(readResource("test_float_null_expected.csv")));
|
|
150
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Test
|
|
154
|
+
public void testCharNull() throws Exception
|
|
155
|
+
{
|
|
156
|
+
Path in1 = toPath("test_char_null.csv");
|
|
157
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_char_null.yml")), in1);
|
|
158
|
+
assertThat(selectRecords(embulk, "TEST_CHAR"), is(readResource("test_char_null_expected.csv")));
|
|
159
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@Test
|
|
163
|
+
public void testVarCharNull() throws Exception
|
|
164
|
+
{
|
|
165
|
+
Path in1 = toPath("test_varchar_null.csv");
|
|
166
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_varchar_null.yml")), in1);
|
|
167
|
+
assertThat(selectRecords(embulk, "TEST_VARCHAR"), is(readResource("test_varchar_null_expected.csv")));
|
|
168
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@Test
|
|
172
|
+
public void testTextNull() throws Exception
|
|
173
|
+
{
|
|
174
|
+
Path in1 = toPath("test_varchar_null.csv");
|
|
175
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_text_null.yml")), in1);
|
|
176
|
+
assertThat(selectRecords(embulk, "TEST_TEXT"), is(readResource("test_varchar_null_expected.csv")));
|
|
177
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@Test
|
|
181
|
+
public void testNCharNull() throws Exception
|
|
182
|
+
{
|
|
183
|
+
Path in1 = toPath("test_char_null.csv");
|
|
184
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_nchar_null.yml")), in1);
|
|
185
|
+
assertThat(selectRecords(embulk, "TEST_NCHAR"), is(readResource("test_char_null_expected.csv")));
|
|
186
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@Test
|
|
190
|
+
public void testNVarCharNull() throws Exception
|
|
191
|
+
{
|
|
192
|
+
Path in1 = toPath("test_varchar_null.csv");
|
|
193
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_nvarchar_null.yml")), in1);
|
|
194
|
+
assertThat(selectRecords(embulk, "TEST_NVARCHAR"), is(readResource("test_varchar_null_expected.csv")));
|
|
195
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@Test
|
|
199
|
+
public void testNTextNull() throws Exception
|
|
200
|
+
{
|
|
201
|
+
Path in1 = toPath("test_varchar_null.csv");
|
|
202
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_ntext_null.yml")), in1);
|
|
203
|
+
assertThat(selectRecords(embulk, "TEST_NTEXT"), is(readResource("test_varchar_null_expected.csv")));
|
|
204
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@Test
|
|
208
|
+
public void testDateNull() throws Exception
|
|
209
|
+
{
|
|
210
|
+
Path in1 = toPath("test_timestamp_null.csv");
|
|
211
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_date_null.yml")), in1);
|
|
212
|
+
assertThat(selectRecords(embulk, "TEST_DATE"), is(readResource("test_date_null_expected.csv")));
|
|
213
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@Test
|
|
217
|
+
public void testDateTimeNull() throws Exception
|
|
218
|
+
{
|
|
219
|
+
Path in1 = toPath("test_timestamp_null.csv");
|
|
220
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_datetime_null.yml")), in1);
|
|
221
|
+
assertThat(selectRecords(embulk, "TEST_DATETIME"), is(readResource("test_datetime_null_expected.csv")));
|
|
222
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@Test
|
|
226
|
+
public void testDateTime2Null() throws Exception
|
|
227
|
+
{
|
|
228
|
+
Path in1 = toPath("test_timestamp_null.csv");
|
|
229
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_datetime2_null.yml")), in1);
|
|
230
|
+
assertThat(selectRecords(embulk, "TEST_DATETIME2"), is(readResource("test_datetime2_null_expected.csv")));
|
|
231
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@Test
|
|
235
|
+
public void testSmallDateTimeNull() throws Exception
|
|
236
|
+
{
|
|
237
|
+
Path in1 = toPath("test_timestamp_null.csv");
|
|
238
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_smalldatetime_null.yml")), in1);
|
|
239
|
+
assertThat(selectRecords(embulk, "TEST_SMALLDATETIME"), is(readResource("test_smalldatetime_null_expected.csv")));
|
|
240
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@Test
|
|
244
|
+
public void testTimeNull() throws Exception
|
|
245
|
+
{
|
|
246
|
+
Path in1 = toPath("test_timestamp_null.csv");
|
|
247
|
+
TestingEmbulk.RunResult result1 = embulk.runOutput(baseConfig.merge(loadYamlResource(embulk, "test_time_null.yml")), in1);
|
|
248
|
+
assertThat(selectRecords(embulk, "TEST_TIME"), is(readResource("test_time_null_expected.csv")));
|
|
249
|
+
//assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private Path toPath(String fileName) throws URISyntaxException
|
|
253
|
+
{
|
|
254
|
+
URL url = Resources.getResource(BASIC_RESOURCE_PATH + fileName);
|
|
255
|
+
return FileSystems.getDefault().getPath(new File(url.toURI()).getAbsolutePath());
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
DROP TABLE TEST_TINYINT;
|
|
2
|
+
CREATE TABLE TEST_TINYINT (
|
|
3
|
+
ID CHAR(4),
|
|
4
|
+
VALUE TINYINT,
|
|
5
|
+
PRIMARY KEY (ID)
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
DROP TABLE TEST_SMALLINT;
|
|
9
|
+
CREATE TABLE TEST_SMALLINT (
|
|
10
|
+
ID CHAR(4),
|
|
11
|
+
VALUE SMALLINT,
|
|
12
|
+
PRIMARY KEY (ID)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
DROP TABLE TEST_INT;
|
|
16
|
+
CREATE TABLE TEST_INT (
|
|
17
|
+
ID CHAR(4),
|
|
18
|
+
VALUE INT,
|
|
19
|
+
PRIMARY KEY (ID)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
DROP TABLE TEST_BIGINT;
|
|
23
|
+
CREATE TABLE TEST_BIGINT (
|
|
24
|
+
ID CHAR(4),
|
|
25
|
+
VALUE BIGINT,
|
|
26
|
+
PRIMARY KEY (ID)
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
DROP TABLE TEST_BIT;
|
|
30
|
+
CREATE TABLE TEST_BIT (
|
|
31
|
+
ID CHAR(4),
|
|
32
|
+
VALUE BIT,
|
|
33
|
+
PRIMARY KEY (ID)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
DROP TABLE TEST_DECIMAL;
|
|
37
|
+
CREATE TABLE TEST_DECIMAL (
|
|
38
|
+
ID CHAR(4),
|
|
39
|
+
VALUE DECIMAL(12,4),
|
|
40
|
+
PRIMARY KEY (ID)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
DROP TABLE TEST_NUMERIC;
|
|
44
|
+
CREATE TABLE TEST_NUMERIC (
|
|
45
|
+
ID CHAR(4),
|
|
46
|
+
VALUE NUMERIC(12,4),
|
|
47
|
+
PRIMARY KEY (ID)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
DROP TABLE TEST_SMALLMONEY;
|
|
51
|
+
CREATE TABLE TEST_SMALLMONEY (
|
|
52
|
+
ID CHAR(4),
|
|
53
|
+
VALUE SMALLMONEY,
|
|
54
|
+
PRIMARY KEY (ID)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
DROP TABLE TEST_MONEY;
|
|
58
|
+
CREATE TABLE TEST_MONEY (
|
|
59
|
+
ID CHAR(4),
|
|
60
|
+
VALUE MONEY,
|
|
61
|
+
PRIMARY KEY (ID)
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
DROP TABLE TEST_BIT;
|
|
65
|
+
CREATE TABLE TEST_BIT (
|
|
66
|
+
ID CHAR(4),
|
|
67
|
+
VALUE BIT,
|
|
68
|
+
PRIMARY KEY (ID)
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
DROP TABLE TEST_REAL;
|
|
72
|
+
CREATE TABLE TEST_REAL (
|
|
73
|
+
ID CHAR(4),
|
|
74
|
+
VALUE REAL,
|
|
75
|
+
PRIMARY KEY (ID)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
DROP TABLE TEST_FLOAT;
|
|
79
|
+
CREATE TABLE TEST_FLOAT (
|
|
80
|
+
ID CHAR(4),
|
|
81
|
+
VALUE FLOAT,
|
|
82
|
+
PRIMARY KEY (ID)
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
DROP TABLE TEST_CHAR;
|
|
86
|
+
CREATE TABLE TEST_CHAR (
|
|
87
|
+
ID INT,
|
|
88
|
+
VALUE CHAR(4),
|
|
89
|
+
PRIMARY KEY (ID)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
DROP TABLE TEST_VARCHAR;
|
|
93
|
+
CREATE TABLE TEST_VARCHAR (
|
|
94
|
+
ID INT,
|
|
95
|
+
VALUE VARCHAR(4),
|
|
96
|
+
PRIMARY KEY (ID)
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
DROP TABLE TEST_TEXT;
|
|
100
|
+
CREATE TABLE TEST_TEXT (
|
|
101
|
+
ID INT,
|
|
102
|
+
VALUE TEXT,
|
|
103
|
+
PRIMARY KEY (ID)
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
DROP TABLE TEST_NCHAR;
|
|
107
|
+
CREATE TABLE TEST_NCHAR (
|
|
108
|
+
ID INT,
|
|
109
|
+
VALUE NCHAR(4),
|
|
110
|
+
PRIMARY KEY (ID)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
DROP TABLE TEST_NVARCHAR;
|
|
114
|
+
CREATE TABLE TEST_NVARCHAR (
|
|
115
|
+
ID INT,
|
|
116
|
+
VALUE NVARCHAR(4),
|
|
117
|
+
PRIMARY KEY (ID)
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
DROP TABLE TEST_NTEXT;
|
|
121
|
+
CREATE TABLE TEST_NTEXT (
|
|
122
|
+
ID INT,
|
|
123
|
+
VALUE NTEXT,
|
|
124
|
+
PRIMARY KEY (ID)
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
DROP TABLE TEST_DATE;
|
|
128
|
+
CREATE TABLE TEST_DATE (
|
|
129
|
+
ID INT,
|
|
130
|
+
VALUE DATE,
|
|
131
|
+
PRIMARY KEY (ID)
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
DROP TABLE TEST_DATETIME;
|
|
135
|
+
CREATE TABLE TEST_DATETIME (
|
|
136
|
+
ID INT,
|
|
137
|
+
VALUE DATETIME,
|
|
138
|
+
PRIMARY KEY (ID)
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
DROP TABLE TEST_DATETIME2;
|
|
142
|
+
CREATE TABLE TEST_DATETIME2 (
|
|
143
|
+
ID INT,
|
|
144
|
+
VALUE DATETIME2,
|
|
145
|
+
PRIMARY KEY (ID)
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
DROP TABLE TEST_SMALLDATETIME;
|
|
149
|
+
CREATE TABLE TEST_SMALLDATETIME (
|
|
150
|
+
ID INT,
|
|
151
|
+
VALUE SMALLDATETIME,
|
|
152
|
+
PRIMARY KEY (ID)
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
DROP TABLE TEST_TIME;
|
|
156
|
+
CREATE TABLE TEST_TIME (
|
|
157
|
+
ID INT,
|
|
158
|
+
VALUE TIME,
|
|
159
|
+
PRIMARY KEY (ID)
|
|
160
|
+
);
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: embulk-output-sqlserver
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sadayuki Furuhashi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Inserts or updates records to 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-output-jdbc-0.7.
|
|
23
|
-
- classpath/embulk-output-sqlserver-0.7.
|
|
22
|
+
- classpath/embulk-output-jdbc-0.7.13.jar
|
|
23
|
+
- classpath/embulk-output-sqlserver-0.7.13.jar
|
|
24
24
|
- classpath/jtds-1.3.1.jar
|
|
25
25
|
- lib/embulk/output/sqlserver.rb
|
|
26
26
|
- src/main/java/org/embulk/output/SQLServerOutputPlugin.java
|
|
@@ -36,6 +36,7 @@ files:
|
|
|
36
36
|
- src/main/java/org/embulk/output/sqlserver/setter/SQLServerColumnSetterFactory.java
|
|
37
37
|
- src/main/java/org/embulk/output/sqlserver/setter/SQLServerSqlTimeColumnSetter.java
|
|
38
38
|
- src/test/java/org/embulk/output/sqlserver/BasicTest.java
|
|
39
|
+
- src/test/java/org/embulk/output/sqlserver/NativeTest.java
|
|
39
40
|
- src/test/java/org/embulk/output/sqlserver/SQLServerTests.java
|
|
40
41
|
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/setup.sql
|
|
41
42
|
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test1.csv
|
|
@@ -58,6 +59,47 @@ files:
|
|
|
58
59
|
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp_expected.csv
|
|
59
60
|
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_truncate_insert.yml
|
|
60
61
|
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_truncate_insert_expected.csv
|
|
62
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/setup.sql
|
|
63
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bigint_null.yml
|
|
64
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bit_null.csv
|
|
65
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bit_null.yml
|
|
66
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_bit_null_expected.csv
|
|
67
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_char_null.csv
|
|
68
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_char_null.yml
|
|
69
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_char_null_expected.csv
|
|
70
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_date_null.yml
|
|
71
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_date_null_expected.csv
|
|
72
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime2_null.yml
|
|
73
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime2_null_expected.csv
|
|
74
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime_null.yml
|
|
75
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_datetime_null_expected.csv
|
|
76
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_decimal_null.csv
|
|
77
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_decimal_null.yml
|
|
78
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_decimal_null_expected.csv
|
|
79
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_float_null.csv
|
|
80
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_float_null.yml
|
|
81
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_float_null_expected.csv
|
|
82
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_int_null.yml
|
|
83
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_integer_null.csv
|
|
84
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_integer_null_expected.csv
|
|
85
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_money_null.yml
|
|
86
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_nchar_null.yml
|
|
87
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_ntext_null.yml
|
|
88
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_numeric_null.yml
|
|
89
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_nvarchar_null.yml
|
|
90
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_real_null.yml
|
|
91
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smalldatetime_null.yml
|
|
92
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smalldatetime_null_expected.csv
|
|
93
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smallint_null.yml
|
|
94
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_smallmoney_null.yml
|
|
95
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_text_null.yml
|
|
96
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_time_null.yml
|
|
97
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_time_null_expected.csv
|
|
98
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_timestamp_null.csv
|
|
99
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_tinyint_null.yml
|
|
100
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_varchar_null.csv
|
|
101
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_varchar_null.yml
|
|
102
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/native/test_varchar_null_expected.csv
|
|
61
103
|
homepage: https://github.com/embulk/embulk-output-jdbc
|
|
62
104
|
licenses:
|
|
63
105
|
- Apache 2.0
|
|
Binary file
|
|
Binary file
|