embulk-input-td 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5116acf36e5cc916233b7556ed561dd26fdfe03
4
- data.tar.gz: 44f9e914b33dcae72942a0448997c0a643a47dd1
3
+ metadata.gz: 48d48f0bf7911cbd6c3a61ce1fc30469f6712a14
4
+ data.tar.gz: e6671f1c0fce07938927855290760b3e71ad7a1d
5
5
  SHA512:
6
- metadata.gz: 48f2daa99ae6a061d9e3f1eabf0944a89e663acb1ff56734eef1be7c3bbfb8fdd764ba3dc80cbc06264d38386435f055e37de7ba4ce2f57f45874c652a953bb3
7
- data.tar.gz: e4e48c965f9cd33ae544b58082a47615e4260631353eab5a7112663966cc979dcfbeffc900fc3fc14f2536aec0aeb12176f3e109e1e4d3d5cc98f2ecdae61a92
6
+ metadata.gz: d62f67b1ce5ea70b56d8c76bc8041218b8c25cb9b421d80ba459206c905a2ff70c6095bf81b87116e170d2e74c9fd9846693a53a76ae9064e8fa54b406e03b54
7
+ data.tar.gz: 0a1b580e1247fc433ac61b3c9728ed511de53e361dafaff90ef153f1bb1395274d799522dfbc016164f6a09b1be97ce5e522a50de066d98332b675ce1ff2bdb3
@@ -1,3 +1,6 @@
1
+ ## 0.2.3 - 2019-08-30
2
+ * [new feature ] Support TIMESTAMP type [#20]
3
+
1
4
  ## 0.2.2 - 2019-08-29
2
5
  * [maintenance] Upgrade td-client, embulk-(core|standards) [#22]
3
6
 
@@ -16,7 +16,7 @@ configurations {
16
16
  provided
17
17
  }
18
18
 
19
- version = "0.2.2"
19
+ version = "0.2.3"
20
20
 
21
21
  sourceCompatibility = 1.8
22
22
  targetCompatibility = 1.8
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "embulk-input-td"
4
- spec.version = "0.2.2"
4
+ spec.version = "0.2.3"
5
5
  spec.authors = ["Muga Nishizawa"]
6
6
  spec.summary = %[Td input plugin for Embulk]
7
7
  spec.description = %[Loads records from Td.]
@@ -34,6 +34,7 @@ import org.embulk.input.td.writer.DoubleValueWriter;
34
34
  import org.embulk.input.td.writer.JsonValueWriter;
35
35
  import org.embulk.input.td.writer.LongValueWriter;
36
36
  import org.embulk.input.td.writer.StringValueWriter;
37
+ import org.embulk.input.td.writer.TimestampValueWriter;
37
38
  import org.embulk.input.td.writer.ValueWriter;
38
39
  import org.embulk.spi.BufferAllocator;
39
40
  import org.embulk.spi.Column;
@@ -233,6 +234,8 @@ public class TdInputPlugin
233
234
  } else if (p.scan("VARCHAR")) {
234
235
  // TODO VARCHAR(n)
235
236
  return Types.STRING;
237
+ } else if (p.scan("TIMESTAMP")) {
238
+ return Types.TIMESTAMP;
236
239
  } else if (p.scan("ARRAY")) {
237
240
  if (!p.scan("(")) {
238
241
  throw new IllegalArgumentException(
@@ -416,8 +419,7 @@ public class TdInputPlugin
416
419
  } else if (type.equals(Types.STRING)) {
417
420
  return new StringValueWriter(column);
418
421
  } else if (type.equals(Types.TIMESTAMP)) {
419
- throw new ConfigException(String.format(Locale.ENGLISH,
420
- "Unsupported column type (%s:%s)", column.getName(), type)); // TODO
422
+ return new TimestampValueWriter(column);
421
423
  } else {
422
424
  throw new ConfigException(String.format(Locale.ENGLISH,
423
425
  "Unsupported column type (%s:%s)", column.getName(), type)); // TODO
@@ -0,0 +1,28 @@
1
+ package org.embulk.input.td.writer;
2
+
3
+ import org.embulk.spi.Column;
4
+ import org.embulk.spi.PageBuilder;
5
+ import org.embulk.spi.time.Timestamp;
6
+ import org.msgpack.value.Value;
7
+ import java.util.Date;
8
+ import java.text.SimpleDateFormat;
9
+
10
+ public class TimestampValueWriter
11
+ extends AbstractValueWriter {
12
+
13
+ public TimestampValueWriter(final Column column) {
14
+ super(column);
15
+ }
16
+
17
+ @Override
18
+ public void writeNotNull(final Value v, final PageBuilder to) {
19
+ try {
20
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
21
+ Date formatedDate = format.parse(v.asStringValue().toString());
22
+ long miliseconds = formatedDate.getTime();
23
+ to.setTimestamp(index, Timestamp.ofEpochMilli(miliseconds));
24
+ } catch (Exception e) {
25
+
26
+ }
27
+ }
28
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muga Nishizawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-29 00:00:00.000000000 Z
11
+ date: 2019-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +67,7 @@ files:
67
67
  - src/main/java/org/embulk/input/td/writer/JsonValueWriter.java
68
68
  - src/main/java/org/embulk/input/td/writer/LongValueWriter.java
69
69
  - src/main/java/org/embulk/input/td/writer/StringValueWriter.java
70
+ - src/main/java/org/embulk/input/td/writer/TimestampValueWriter.java
70
71
  - src/main/java/org/embulk/input/td/writer/ValueWriter.java
71
72
  - src/test/java/org/embulk/input/td/TestTdInputPlugin.java
72
73
  - classpath/jackson-core-2.9.9.jar
@@ -74,7 +75,7 @@ files:
74
75
  - classpath/jackson-datatype-json-org-2.9.9.jar
75
76
  - classpath/okhttp-3.12.0.jar
76
77
  - classpath/junit-4.10.jar
77
- - classpath/embulk-input-td-0.2.2.jar
78
+ - classpath/embulk-input-td-0.2.3.jar
78
79
  - classpath/json-20171018.jar
79
80
  - classpath/guava-21.0.jar
80
81
  - classpath/jackson-datatype-guava-2.9.9.jar