embulk-input-jdbc 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04a66446f33cb93478fac400edddfde76fc16a3b
4
- data.tar.gz: b8bcffe863fa757da3124c6a6d9b82b317d0662f
3
+ metadata.gz: ef30f93f35dcbdd6db4b36511bf5f75b883a1ec6
4
+ data.tar.gz: e0b9ea62c7511c819633d6ae91f54fa61403bcd4
5
5
  SHA512:
6
- metadata.gz: f20fedd3f5d22ac57067b83e4dbd6038c5f69acca74a810af84934e1a988dd5acc3ae16afe960324f929a37e2c7bbbd8e6194de4f1195632446001a5915d78ee
7
- data.tar.gz: 4176be4dafda7373475ccd04e198ed27c809b1853590617ac10f3da1c058082ea61169bff33791f0f431ccdfb8ee46b564ebe96c312a22382877354ece647e04
6
+ metadata.gz: 8ebe087f0a16081df0bc640b2916661357e41190bcaaa7c4b0bf6bec80dba033bbc740a670893f8b8f49699effb0ab93caf8bd290eda838c9c91f85a65941f95
7
+ data.tar.gz: e560eb0880aca36c5bde61c17e1f80ff64fcd4c2a4c619402e2d3a1983c1d533de786a9f75fe98e35e0e63dcb34332d7bd8916721a26caa485ca2eb1d128ca16
@@ -9,6 +9,7 @@ import org.embulk.input.jdbc.getter.ColumnGetters.StringColumnGetter;
9
9
  import org.embulk.input.jdbc.getter.ColumnGetters.DateColumnGetter;
10
10
  import org.embulk.input.jdbc.getter.ColumnGetters.TimeColumnGetter;
11
11
  import org.embulk.input.jdbc.getter.ColumnGetters.TimestampColumnGetter;
12
+ import org.embulk.input.jdbc.getter.ColumnGetters.BigDecimalToDoubleColumnGetter;
12
13
 
13
14
  public class ColumnGetterFactory
14
15
  {
@@ -22,18 +23,18 @@ public class ColumnGetterFactory
22
23
  case Types.BIGINT:
23
24
  return new LongColumnGetter();
24
25
 
25
- // setDouble
26
+ // getDouble
26
27
  case Types.DOUBLE:
27
28
  case Types.FLOAT:
28
29
  case Types.REAL:
29
30
  return new DoubleColumnGetter();
30
31
 
31
- // setBool
32
+ // getBool
32
33
  case Types.BOOLEAN:
33
34
  case Types.BIT: // JDBC BIT is boolean, unlike SQL-92
34
35
  return new BooleanColumnGetter();
35
36
 
36
- // setString, Clob
37
+ // getString, Clob
37
38
  case Types.CHAR:
38
39
  case Types.VARCHAR:
39
40
  case Types.LONGVARCHAR:
@@ -44,7 +45,7 @@ public class ColumnGetterFactory
44
45
  return new StringColumnGetter();
45
46
 
46
47
  // TODO
47
- //// setBytes Blob
48
+ //// getBytes Blob
48
49
  //case Types.BINARY:
49
50
  //case Types.VARBINARY:
50
51
  //case Types.LONGVARBINARY:
@@ -68,11 +69,10 @@ public class ColumnGetterFactory
68
69
  //case Types.NULL:
69
70
  // return new NullColumnGetter();
70
71
 
71
- // TODO
72
- //// BigDecimal
73
- //case Types.NUMERIC:
74
- //case Types.DECIMAL:
75
- // return new BigDecimalColumnGetter();
72
+ // getBigDecimal
73
+ case Types.NUMERIC:
74
+ case Types.DECIMAL:
75
+ return new BigDecimalToDoubleColumnGetter();
76
76
 
77
77
  // others
78
78
  case Types.ARRAY: // array
@@ -92,8 +92,7 @@ public class ColumnGetterFactory
92
92
  private static UnsupportedOperationException unsupportedOperationException(JdbcColumn column)
93
93
  {
94
94
  throw new UnsupportedOperationException(
95
- String.format("Unsupported type %s (sqlType=%d)",
96
- column.getTypeName(), column.getSqlType()));
95
+ String.format("Unsupported type %s (sqlType=%d) of '%s' column. Please exclude the column from 'select:' option.",
96
+ column.getTypeName(), column.getSqlType(), column.getName()));
97
97
  }
98
98
  }
99
-
@@ -2,6 +2,7 @@ package org.embulk.input.jdbc.getter;
2
2
 
3
3
  import java.sql.ResultSet;
4
4
  import java.sql.SQLException;
5
+ import java.math.BigDecimal;
5
6
  import org.embulk.spi.Column;
6
7
  import org.embulk.spi.PageBuilder;
7
8
  import org.embulk.spi.Column;
@@ -169,4 +170,28 @@ public class ColumnGetters
169
170
  return Types.TIMESTAMP.withFormat("%Y-%m-%d %H:%M:%S");
170
171
  }
171
172
  }
173
+
174
+ public static class BigDecimalToDoubleColumnGetter
175
+ implements ColumnGetter
176
+ {
177
+ @Override
178
+ public void getAndSet(ResultSet from, int fromIndex,
179
+ PageBuilder to, Column toColumn) throws SQLException
180
+ {
181
+ BigDecimal v = from.getBigDecimal(fromIndex);
182
+ if (from.wasNull()) {
183
+ to.setNull(toColumn);
184
+ } else {
185
+ // rounded value could be Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY.
186
+ double rounded = v.doubleValue();
187
+ to.setDouble(toColumn, rounded);
188
+ }
189
+ }
190
+
191
+ @Override
192
+ public Type getToType()
193
+ {
194
+ return Types.DOUBLE;
195
+ }
196
+ }
172
197
  }
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - FURUHASHI Sadayuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: JDBC input plugin is an Embulk plugin that loads records from JDBC so that any output plugins can receive the records. Search the output plugins by "embulk-output" keyword.
14
14
  email:
@@ -26,7 +26,7 @@ files:
26
26
  - src/main/java/org/embulk/input/jdbc/getter/ColumnGetter.java
27
27
  - src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java
28
28
  - src/main/java/org/embulk/input/jdbc/getter/ColumnGetters.java
29
- - classpath/embulk-input-jdbc-0.2.0.jar
29
+ - classpath/embulk-input-jdbc-0.2.1.jar
30
30
  homepage: https://github.com/embulk/embulk-input-jdbc
31
31
  licenses:
32
32
  - Apache 2.0
Binary file