embulk-output-td 0.3.15 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -2
- data/build.gradle +2 -2
- data/embulk-output-td.gemspec +1 -1
- data/src/main/java/org/embulk/output/td/TdOutputPlugin.java +26 -13
- data/src/test/java/org/embulk/output/td/TestTdOutputPlugin.java +3 -15
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11b5c3e330412f6124619e5a42b1a2752c2fe163
|
4
|
+
data.tar.gz: cc39b754466f6bd06fa4f2148235d29991d7c899
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00286be234967a6693ee52c3c06042dc7e49be1ccfe8ecb4f4f4a0df4d7fe265394f57a4ef27c0628798d4ca7d0a3a0d343b63c065a38490d3e64beb2a3bbfd
|
7
|
+
data.tar.gz: e6e5f805e8a1630d1a5cc768e018df977496ca605042a783a2294111d241d080691f79a183cee37ae06133bf3535f2947e3ef78c24e17ca71b468f8ca5b8a150
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.4.0 - 2017-06-26
|
2
|
+
|
3
|
+
* [maintenance] Use TDClient#showTable method to to get table schema [#64](https://github.com/treasure-data/embulk-output-td/pull/64)
|
4
|
+
* [maintenance] Use TDClient#appendTableSchema method to update table schema [#65](https://github.com/treasure-data/embulk-output-td/pull/65)
|
5
|
+
|
1
6
|
## 0.3.15 - 2017-05-30
|
2
7
|
|
3
8
|
* [fix bug] Use underscores for sessions names to fix #70 [#71](https://github.com/treasure-data/embulk-output-td/pull/71)
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# TD output plugin for Embulk
|
2
2
|
|
3
|
-
|
3
|
+
[Treasure Data Service](https://www.treasuredata.com/) output plugin for [Embulk](https://github.com/embulk/embulk)
|
4
|
+
|
5
|
+
**NOTICE**: embulk-output-td v0.4.0+ only supports **Embulk v0.8.22+**.
|
4
6
|
|
5
7
|
## Overview
|
6
8
|
|
@@ -110,4 +112,4 @@ Repo URL: https://rubygems.org/gems/embulk-output-td
|
|
110
112
|
$ ./gradlew bintrayUpload
|
111
113
|
```
|
112
114
|
|
113
|
-
Repo URL: https://bintray.com/embulk-output-td/maven/embulk-output-td
|
115
|
+
Repo URL: https://bintray.com/embulk-output-td/maven/embulk-output-td
|
data/build.gradle
CHANGED
@@ -19,7 +19,7 @@ configurations {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
group = "org.embulk.output.td"
|
22
|
-
version = "0.
|
22
|
+
version = "0.4.0"
|
23
23
|
|
24
24
|
compileJava.options.encoding = 'UTF-8' // source encoding
|
25
25
|
sourceCompatibility = 1.7
|
@@ -32,7 +32,7 @@ dependencies {
|
|
32
32
|
provided "org.embulk:embulk-standards:0.8.+"
|
33
33
|
compile "org.msgpack:msgpack-core:0.8.+"
|
34
34
|
provided "org.msgpack:msgpack-core:0.8.+"
|
35
|
-
compile
|
35
|
+
compile "com.treasuredata.client:td-client:0.7.38"
|
36
36
|
|
37
37
|
testCompile "junit:junit:4.+"
|
38
38
|
testCompile "org.bigtesting:fixd:1.0.0"
|
data/embulk-output-td.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "embulk-output-td"
|
4
|
-
spec.version = "0.
|
4
|
+
spec.version = "0.4.0"
|
5
5
|
spec.authors = ["Muga Nishizawa"]
|
6
6
|
spec.summary = %[TreasureData output plugin for Embulk]
|
7
7
|
spec.description = %[TreasureData output plugin is an Embulk plugin that loads records to TreasureData read by any input plugins. Search the input plugins by 'embulk-output' keyword.]
|
@@ -33,6 +33,7 @@ import com.treasuredata.client.model.TDBulkImportSession.ImportStatus;
|
|
33
33
|
import com.treasuredata.client.model.TDColumn;
|
34
34
|
import com.treasuredata.client.model.TDColumnType;
|
35
35
|
import com.treasuredata.client.model.TDTable;
|
36
|
+
import org.embulk.EmbulkVersion;
|
36
37
|
import org.embulk.config.TaskReport;
|
37
38
|
import org.embulk.config.Config;
|
38
39
|
import org.embulk.config.ConfigDefault;
|
@@ -356,6 +357,8 @@ public class TdOutputPlugin
|
|
356
357
|
task.setTempDir(Optional.of(getEnvironmentTempDirectory()));
|
357
358
|
}
|
358
359
|
|
360
|
+
checkEmbulkVersion();
|
361
|
+
|
359
362
|
try (TDClient client = newTDClient(task)) {
|
360
363
|
String databaseName = task.getDatabase();
|
361
364
|
String tableName = task.getTable();
|
@@ -555,15 +558,10 @@ public class TdOutputPlugin
|
|
555
558
|
void validateTableExists(TDClient client, String databaseName, String tableName)
|
556
559
|
{
|
557
560
|
try {
|
558
|
-
|
559
|
-
if (table.getName().equals(tableName)) {
|
560
|
-
return;
|
561
|
-
}
|
562
|
-
}
|
563
|
-
throw new ConfigException(String.format("Table \"%s\".\"%s\" doesn't exist", databaseName, tableName));
|
561
|
+
client.showTable(databaseName, tableName);
|
564
562
|
}
|
565
563
|
catch (TDClientHttpNotFoundException ex) {
|
566
|
-
throw new ConfigException(String.format("Database \"%s\" doesn't exist", databaseName), ex);
|
564
|
+
throw new ConfigException(String.format("Database \"%s\" or table \"%s\" doesn't exist", databaseName, tableName), ex);
|
567
565
|
}
|
568
566
|
}
|
569
567
|
|
@@ -754,7 +752,7 @@ public class TdOutputPlugin
|
|
754
752
|
newSchema.add(new TDColumn(pair.getKey(), pair.getValue(), key.getBytes(StandardCharsets.UTF_8)));
|
755
753
|
}
|
756
754
|
|
757
|
-
client.
|
755
|
+
client.appendTableSchema(databaseName, task.getLoadTargetTableName(), newSchema);
|
758
756
|
return guessedSchema;
|
759
757
|
}
|
760
758
|
|
@@ -770,12 +768,12 @@ public class TdOutputPlugin
|
|
770
768
|
|
771
769
|
private static TDTable findTable(TDClient client, String databaseName, String tableName)
|
772
770
|
{
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
771
|
+
try {
|
772
|
+
return client.showTable(databaseName, tableName);
|
773
|
+
}
|
774
|
+
catch(TDClientHttpNotFoundException e) {
|
775
|
+
return null;
|
777
776
|
}
|
778
|
-
return null;
|
779
777
|
}
|
780
778
|
|
781
779
|
private static final Pattern COLUMN_NAME_PATTERN = Pattern.compile("\\A[a-z_][a-z0-9_]*\\z");
|
@@ -817,6 +815,21 @@ public class TdOutputPlugin
|
|
817
815
|
});
|
818
816
|
}
|
819
817
|
|
818
|
+
private void checkEmbulkVersion()
|
819
|
+
{
|
820
|
+
// Embulk v0.8.21 and lower version uses old Jackson and doesn't works with this plugin
|
821
|
+
// https://github.com/embulk/embulk/pull/615
|
822
|
+
String[] versionNumber = EmbulkVersion.VERSION.split("-"); // to split e.g. "0.8.26-SNAPSHOT" or "0.8.30-ALPHA1"
|
823
|
+
if (versionNumber[0] != null) {
|
824
|
+
String[] versions = versionNumber[0].split("\\.");
|
825
|
+
if (versions.length == 3) {
|
826
|
+
if (Integer.valueOf(versions[1]) <= 8 && Integer.valueOf(versions[2]) < 22) {
|
827
|
+
throw new ConfigException("embulk-output-td v0.4.x+ only supports Embulk v0.8.22 or higher versions");
|
828
|
+
}
|
829
|
+
}
|
830
|
+
}
|
831
|
+
}
|
832
|
+
|
820
833
|
@VisibleForTesting
|
821
834
|
TDBulkImportSession waitForStatusChange(TDClient client, String sessionName,
|
822
835
|
ImportStatus current, ImportStatus expecting, String operation)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
package org.embulk.output.td;
|
2
2
|
|
3
3
|
import com.google.common.base.Optional;
|
4
|
-
import com.google.common.collect.ImmutableList;
|
5
4
|
import com.google.common.collect.ImmutableMap;
|
6
5
|
import com.google.common.collect.Lists;
|
7
6
|
import com.treasuredata.client.ProxyConfig;
|
@@ -333,24 +332,13 @@ public class TestTdOutputPlugin
|
|
333
332
|
TDTable table = newTable("my_table", "[]");
|
334
333
|
|
335
334
|
{ // table exists
|
336
|
-
doReturn(
|
335
|
+
doReturn(table).when(client).showTable(anyString(), anyString());
|
337
336
|
plugin.validateTableExists(client, "my_db", "my_table");
|
338
337
|
// no error happens
|
339
338
|
}
|
340
339
|
|
341
|
-
{ // table doesn't exist
|
342
|
-
|
343
|
-
try {
|
344
|
-
plugin.validateTableExists(client, "my_db", "my_table");
|
345
|
-
fail();
|
346
|
-
}
|
347
|
-
catch (Throwable t) {
|
348
|
-
assertTrue(t instanceof ConfigException);
|
349
|
-
}
|
350
|
-
}
|
351
|
-
|
352
|
-
{ // database doesn't exist
|
353
|
-
doThrow(notFound()).when(client).listTables(anyString());
|
340
|
+
{ // database or table doesn't exist
|
341
|
+
doThrow(notFound()).when(client).showTable(anyString(), anyString());
|
354
342
|
try {
|
355
343
|
plugin.validateTableExists(client, "my_db", "my_table");
|
356
344
|
fail();
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-td
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muga Nishizawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
14
|
+
name: bundler
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - ~>
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '1.0'
|
19
|
-
|
20
|
-
prerelease: false
|
21
|
-
type: :development
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
23
21
|
requirements:
|
24
22
|
- - ~>
|
25
23
|
- !ruby/object:Gem::Version
|
26
24
|
version: '1.0'
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
|
28
|
+
name: rake
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '10.0'
|
33
|
-
|
34
|
-
prerelease: false
|
35
|
-
type: :development
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
37
35
|
requirements:
|
38
36
|
- - '>='
|
39
37
|
- !ruby/object:Gem::Version
|
40
38
|
version: '10.0'
|
39
|
+
prerelease: false
|
40
|
+
type: :development
|
41
41
|
description: TreasureData output plugin is an Embulk plugin that loads records to TreasureData read by any input plugins. Search the input plugins by 'embulk-output' keyword.
|
42
42
|
email:
|
43
43
|
- muga.nishizawa@gmail.com
|
@@ -82,7 +82,7 @@ files:
|
|
82
82
|
- src/test/java/org/embulk/output/td/TestTdOutputPlugin.java
|
83
83
|
- src/test/java/org/embulk/output/td/TestTimeValueGenerator.java
|
84
84
|
- src/test/java/org/embulk/output/td/writer/TestFieldWriterSet.java
|
85
|
-
- classpath/embulk-output-td-0.
|
85
|
+
- classpath/embulk-output-td-0.4.0.jar
|
86
86
|
- classpath/hamcrest-core-1.1.jar
|
87
87
|
- classpath/jackson-datatype-json-org-2.6.7.jar
|
88
88
|
- classpath/jetty-client-9.2.2.v20140723.jar
|
@@ -92,7 +92,7 @@ files:
|
|
92
92
|
- classpath/json-20090211_1.jar
|
93
93
|
- classpath/json-simple-1.1.1.jar
|
94
94
|
- classpath/junit-4.10.jar
|
95
|
-
- classpath/td-client-0.7.
|
95
|
+
- classpath/td-client-0.7.38.jar
|
96
96
|
homepage: https://github.com/treasure-data/embulk-output-td
|
97
97
|
licenses:
|
98
98
|
- Apache 2.0
|