embulk-input-jdbc 0.8.5 → 0.8.6

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: debd726a2754ee5ffa81e8b0a19b6f0962edf7e0
4
- data.tar.gz: 4fa93d96dc225cf41687ee60b29b4d9d17fc9622
3
+ metadata.gz: 617c1a978aee468e9f849b9defa0ef3e44d53de5
4
+ data.tar.gz: 28a1d38053028001e4c2a80f2de513c05d2317c0
5
5
  SHA512:
6
- metadata.gz: 068f25c21264c1d42cdc1634a3b3a61da127d8e0e859c8cdfeeebb20aa1d35eebd716495dd09ab2903e7d06722bf107a21b911a1c43337f35502f7c0768df928
7
- data.tar.gz: d7c1829e071c1123b8877ff22679c4a51f3bf59eaca512620e685690012ce976b3e41ed6a958837f0cf09be8dcbfed2c408ccf0728354b4411febb0a701a784d
6
+ metadata.gz: 0e891c2884ed461185c87f2634b56d4fa12773c9c271fa53e10d3b0fbb5397c56e321a4111c68fdcec0b30d870f5d58b48afbb18a9632140115ea41fedd39adc
7
+ data.tar.gz: 3266593494c05a45ebb1a38ec79286f466d9457e23a8cfa5eb3b3ef86e0dead5bf5aa1773bc90767e3b2126a504a4d92e2844362da689bdba8e8439ed8359626
data/README.md CHANGED
@@ -62,7 +62,7 @@ At the next execution, when `last_record: ` is also set, this plugin generates a
62
62
  SELECT * FROM (
63
63
  ...original query is here...
64
64
  )
65
- WHERE created_at > '2017-01-01 00:32:12' OR (created_at = '2017-01-01 00:32:12' AND id > 5291)
65
+ WHERE updated_at > '2017-01-01 00:32:12' OR (updated_at = '2017-01-01 00:32:12' AND id > 5291)
66
66
  ORDER BY updated_at, id
67
67
  ```
68
68
 
@@ -7,7 +7,6 @@ import org.embulk.config.Task;
7
7
  import org.embulk.spi.time.TimestampFormat;
8
8
  import org.embulk.spi.type.Type;
9
9
  import org.joda.time.DateTimeZone;
10
- import org.jruby.embed.ScriptingContainer;
11
10
 
12
11
  import com.google.common.base.Optional;
13
12
 
@@ -29,8 +28,4 @@ public interface JdbcColumnOption
29
28
  @Config("timezone")
30
29
  @ConfigDefault("null")
31
30
  public Optional<DateTimeZone> getTimeZone();
32
-
33
- // required by TimestampFormatter
34
- @ConfigInject
35
- public ScriptingContainer getJRuby();
36
31
  }
@@ -5,11 +5,15 @@ import java.sql.Types;
5
5
  import java.util.HashMap;
6
6
  import java.util.Map;
7
7
 
8
+ import com.google.common.base.Optional;
8
9
  import org.embulk.config.ConfigException;
10
+ import org.embulk.config.ConfigSource;
11
+ import org.embulk.config.Task;
9
12
  import org.embulk.input.jdbc.AbstractJdbcInputPlugin.PluginTask;
10
13
  import org.embulk.input.jdbc.JdbcColumn;
11
14
  import org.embulk.input.jdbc.JdbcColumnOption;
12
15
  import org.embulk.input.jdbc.JdbcInputConnection;
16
+ import org.embulk.spi.Exec;
13
17
  import org.embulk.spi.PageBuilder;
14
18
  import org.embulk.spi.time.TimestampFormatter;
15
19
  import org.embulk.spi.type.TimestampType;
@@ -176,12 +180,21 @@ public class ColumnGetterFactory
176
180
  return toType;
177
181
  }
178
182
 
183
+ private static interface FormatterIntlTask extends Task, TimestampFormatter.Task {}
184
+ private static interface FormatterIntlColumnOption extends Task, TimestampFormatter.TimestampColumnOption {}
185
+
179
186
  private TimestampFormatter newTimestampFormatter(JdbcColumnOption option, String defaultTimestampFormat)
180
187
  {
188
+ // TODO: Switch to a newer TimestampFormatter constructor after a reasonable interval.
189
+ // Traditional constructor is used here for compatibility.
190
+ final ConfigSource configSource = Exec.newConfigSource();
191
+ configSource.set("format", option.getTimestampFormat().isPresent()
192
+ ? option.getTimestampFormat().get().getFormat()
193
+ : defaultTimestampFormat);
194
+ configSource.set("timezone", option.getTimeZone().or(this.defaultTimeZone));
181
195
  return new TimestampFormatter(
182
- option.getJRuby(),
183
- option.getTimestampFormat().isPresent() ? option.getTimestampFormat().get().getFormat() : defaultTimestampFormat,
184
- option.getTimeZone().or(defaultTimeZone));
196
+ Exec.newConfigSource().loadConfig(FormatterIntlTask.class),
197
+ Optional.fromNullable(configSource.loadConfig(FormatterIntlColumnOption.class)));
185
198
  }
186
199
 
187
200
  private static UnsupportedOperationException unsupportedOperationException(JdbcColumn column)
@@ -1,15 +1,16 @@
1
1
  package org.embulk.input.jdbc.getter;
2
2
 
3
3
  import com.fasterxml.jackson.databind.JsonNode;
4
+ import com.google.common.base.Optional;
4
5
  import java.sql.PreparedStatement;
5
6
  import java.sql.ResultSet;
6
7
  import java.sql.SQLException;
7
8
  import java.sql.Timestamp;
9
+ import org.embulk.config.ConfigSource;
10
+ import org.embulk.config.Task;
8
11
  import org.embulk.spi.Column;
9
12
  import org.embulk.spi.Exec;
10
- import org.embulk.spi.time.TimestampFormatter.FormatterTask;
11
13
  import org.embulk.spi.time.TimestampFormatter;
12
- import org.embulk.spi.time.TimestampParser.ParserTask;
13
14
  import org.embulk.spi.time.TimestampParser;
14
15
 
15
16
  public class TimestampWithTimeZoneIncrementalHandler
@@ -40,25 +41,39 @@ public class TimestampWithTimeZoneIncrementalHandler
40
41
  super.getAndSet(from, fromIndex, toColumn);
41
42
  }
42
43
 
44
+ private static interface FormatterIntlTask extends Task, TimestampFormatter.Task {}
45
+ private static interface FormatterIntlColumnOption extends Task, TimestampFormatter.TimestampColumnOption {}
46
+
43
47
  @Override
44
48
  public JsonNode encodeToJson()
45
49
  {
46
- FormatterTask task = Exec.newConfigSource()
47
- .set("timezone", "UTC")
48
- .loadConfig(FormatterTask.class);
49
- TimestampFormatter formatter = new TimestampFormatter(ISO_USEC_FORMAT, task);
50
+ // TODO: Switch to a newer TimestampFormatter constructor after a reasonable interval.
51
+ // Traditional constructor is used here for compatibility.
52
+ final ConfigSource configSource = Exec.newConfigSource();
53
+ configSource.set("format", ISO_USEC_FORMAT);
54
+ configSource.set("timezone", "UTC");
55
+ TimestampFormatter formatter = new TimestampFormatter(
56
+ Exec.newConfigSource().loadConfig(FormatterIntlTask.class),
57
+ Optional.fromNullable(configSource.loadConfig(FormatterIntlColumnOption.class)));
50
58
  String text = formatter.format(org.embulk.spi.time.Timestamp.ofEpochSecond(epochSecond, nano));
51
59
  return jsonNodeFactory.textNode(text);
52
60
  }
53
61
 
62
+ private static interface ParserIntlTask extends Task, TimestampParser.Task {}
63
+ private static interface ParserIntlColumnOption extends Task, TimestampParser.TimestampColumnOption {}
64
+
54
65
  @Override
55
66
  public void decodeFromJsonTo(PreparedStatement toStatement, int toIndex, JsonNode fromValue)
56
67
  throws SQLException
57
68
  {
58
- ParserTask task = Exec.newConfigSource()
59
- .set("default_timezone", "UTC")
60
- .loadConfig(ParserTask.class);
61
- TimestampParser parser = new TimestampParser(ISO_USEC_PATTERN, task);
69
+ // TODO: Switch to a newer TimestampParser constructor after a reasonable interval.
70
+ // Traditional constructor is used here for compatibility.
71
+ final ConfigSource configSource = Exec.newConfigSource();
72
+ configSource.set("format", ISO_USEC_PATTERN);
73
+ configSource.set("timezone", "UTC");
74
+ TimestampParser parser = new TimestampParser(
75
+ Exec.newConfigSource().loadConfig(ParserIntlTask.class),
76
+ configSource.loadConfig(ParserIntlColumnOption.class));
62
77
  org.embulk.spi.time.Timestamp epoch = parser.parse(fromValue.asText());
63
78
 
64
79
  Timestamp sqlTimestamp = new Timestamp(epoch.getEpochSecond() * 1000);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-jdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
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-07-31 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selects records from a table.
14
14
  email:
@@ -19,7 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - README.md
21
21
  - build.gradle
22
- - classpath/embulk-input-jdbc-0.8.5.jar
22
+ - classpath/embulk-input-jdbc-0.8.6.jar
23
23
  - lib/embulk/input/jdbc.rb
24
24
  - src/main/java/org/embulk/input/JdbcInputPlugin.java
25
25
  - src/main/java/org/embulk/input/jdbc/AbstractJdbcInputPlugin.java
Binary file