embulk-input-jdbc 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/classpath/embulk-input-jdbc-0.5.0.jar +0 -0
  3. data/src/main/java/org/embulk/input/JdbcInputPlugin.java +0 -8
  4. data/src/main/java/org/embulk/input/jdbc/AbstractJdbcInputPlugin.java +51 -13
  5. data/src/main/java/org/embulk/input/jdbc/JdbcColumn.java +20 -1
  6. data/src/main/java/org/embulk/input/jdbc/JdbcColumnOption.java +36 -0
  7. data/src/main/java/org/embulk/input/jdbc/JdbcInputConnection.java +4 -4
  8. data/src/main/java/org/embulk/input/jdbc/getter/AbstractColumnGetter.java +76 -0
  9. data/src/main/java/org/embulk/input/jdbc/getter/AbstractTimestampColumnGetter.java +33 -0
  10. data/src/main/java/org/embulk/input/jdbc/getter/BigDecimalColumnGetter.java +59 -0
  11. data/src/main/java/org/embulk/input/jdbc/getter/BooleanColumnGetter.java +56 -0
  12. data/src/main/java/org/embulk/input/jdbc/getter/ColumnGetter.java +1 -2
  13. data/src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java +86 -20
  14. data/src/main/java/org/embulk/input/jdbc/getter/DateColumnGetter.java +37 -0
  15. data/src/main/java/org/embulk/input/jdbc/getter/DoubleColumnGetter.java +66 -0
  16. data/src/main/java/org/embulk/input/jdbc/getter/FloatColumnGetter.java +66 -0
  17. data/src/main/java/org/embulk/input/jdbc/getter/LongColumnGetter.java +56 -0
  18. data/src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java +64 -0
  19. data/src/main/java/org/embulk/input/jdbc/getter/TimeColumnGetter.java +37 -0
  20. data/src/main/java/org/embulk/input/jdbc/getter/TimestampColumnGetter.java +36 -0
  21. metadata +15 -4
  22. data/classpath/embulk-input-jdbc-0.4.0.jar +0 -0
  23. data/src/main/java/org/embulk/input/jdbc/getter/ColumnGetters.java +0 -197
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c8e7bcef7a17ff17d0765398c37a01e30069d1e
4
- data.tar.gz: e8da2a078d57ea323a94e4e12228ec38aa9ebff8
3
+ metadata.gz: 58343b1cbca7d7302990e5ae707abd6093c50a6e
4
+ data.tar.gz: 1f20480bd02215e50e9e297ab71b8edbf7737f1a
5
5
  SHA512:
6
- metadata.gz: 31f6a9698536e5bb62c795a43a0a7215e3f6c654c3fdacf3155702903699146187953dee40c60da4cb9358fe6e6b420f53ea94511ef4e099d4bd71defee6a305
7
- data.tar.gz: 6e95e49f74ac0d529486b610713d75f8372d619fd4fcc47847a2ea908263c0a1aa593a7fbaf7ddc691d4854d0506405c3d8dc83395d377f99c4e1a071e8debb6
6
+ metadata.gz: a79c9b92ca7b98df26ad863382a8351266b1acaebfb218429000e47132a081afe692f3ba2f543bbb6a2bf768e2eba756cc4fe510c184eb941858ca04fd9e854f
7
+ data.tar.gz: cf26a3cbf0ece3949506e6ac9f282eb08c338f39bb9b1cb929b09a2bad9fcaf5d3d08703090dea09a27ebe740cb562382dc55422acf06f9776adfd916abcfb7b
@@ -1,6 +1,5 @@
1
1
  package org.embulk.input;
2
2
 
3
- import java.nio.file.Paths;
4
3
  import java.util.Set;
5
4
  import java.util.HashSet;
6
5
  import java.util.Properties;
@@ -9,7 +8,6 @@ import java.sql.Driver;
9
8
  import java.sql.SQLException;
10
9
  import com.google.common.base.Optional;
11
10
  import com.google.common.base.Throwables;
12
- import org.embulk.spi.PluginClassLoader;
13
11
  import org.embulk.config.Config;
14
12
  import org.embulk.config.ConfigDefault;
15
13
  import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
@@ -98,10 +96,4 @@ public class JdbcInputPlugin
98
96
  }
99
97
  }
100
98
 
101
- private void loadDriverJar(String glob)
102
- {
103
- // TODO match glob
104
- PluginClassLoader loader = (PluginClassLoader) getClass().getClassLoader();
105
- loader.addPath(Paths.get(glob));
106
- }
107
99
  }
@@ -1,13 +1,19 @@
1
1
  package org.embulk.input.jdbc;
2
2
 
3
3
  import java.util.List;
4
+ import java.util.Map;
4
5
  import java.util.Properties;
6
+ import java.nio.file.Paths;
5
7
  import java.sql.ResultSet;
6
8
  import java.sql.SQLException;
9
+
7
10
  import org.slf4j.Logger;
11
+
8
12
  import com.google.common.base.Optional;
13
+ import com.google.common.base.Supplier;
9
14
  import com.google.common.base.Throwables;
10
15
  import com.google.common.collect.ImmutableList;
16
+
11
17
  import org.embulk.config.CommitReport;
12
18
  import org.embulk.config.Config;
13
19
  import org.embulk.config.ConfigException;
@@ -22,11 +28,13 @@ import org.embulk.spi.Column;
22
28
  import org.embulk.spi.PageBuilder;
23
29
  import org.embulk.spi.InputPlugin;
24
30
  import org.embulk.spi.PageOutput;
31
+ import org.embulk.spi.PluginClassLoader;
25
32
  import org.embulk.spi.Schema;
26
33
  import org.embulk.spi.Exec;
27
34
  import org.embulk.input.jdbc.getter.ColumnGetter;
28
35
  import org.embulk.input.jdbc.getter.ColumnGetterFactory;
29
36
  import org.embulk.input.jdbc.JdbcInputConnection.BatchSelect;
37
+ import org.joda.time.DateTimeZone;
30
38
 
31
39
  public abstract class AbstractJdbcInputPlugin
32
40
  implements InputPlugin
@@ -97,6 +105,14 @@ public abstract class AbstractJdbcInputPlugin
97
105
 
98
106
  // TODO parallel execution using "partition_by" config
99
107
 
108
+ @Config("column_options")
109
+ @ConfigDefault("{}")
110
+ public Map<String, JdbcColumnOption> getColumnOptions();
111
+
112
+ @Config("default_timezone")
113
+ @ConfigDefault("\"UTC\"")
114
+ public DateTimeZone getDefaultTimeZone();
115
+
100
116
  public JdbcSchema getQuerySchema();
101
117
  public void setQuerySchema(JdbcSchema schema);
102
118
 
@@ -112,11 +128,6 @@ public abstract class AbstractJdbcInputPlugin
112
128
 
113
129
  protected abstract JdbcInputConnection newConnection(PluginTask task) throws SQLException;
114
130
 
115
- protected ColumnGetterFactory newColumnGetterFactory(PluginTask task) throws SQLException
116
- {
117
- return new ColumnGetterFactory();
118
- }
119
-
120
131
  @Override
121
132
  public ConfigDiff transaction(ConfigSource config,
122
133
  InputPlugin.Control control)
@@ -143,12 +154,17 @@ public abstract class AbstractJdbcInputPlugin
143
154
  JdbcSchema querySchema = con.getSchemaOfQuery(getQuery(task, con));
144
155
  task.setQuerySchema(querySchema);
145
156
 
146
- ColumnGetterFactory factory = newColumnGetterFactory(task);
157
+ // validate column_options
158
+ newColumnGetters(task, querySchema, null);
159
+
160
+ ColumnGetterFactory factory = new ColumnGetterFactory(null, task.getDefaultTimeZone());
147
161
  ImmutableList.Builder<Column> columns = ImmutableList.builder();
148
162
  for (int i = 0; i < querySchema.getCount(); i++) {
163
+ JdbcColumn column = querySchema.getColumn(i);
164
+ JdbcColumnOption columnOption = columnOptionOf(task.getColumnOptions(), column);
149
165
  columns.add(new Column(i,
150
- querySchema.getColumnName(i),
151
- factory.newColumnGetter(querySchema.getColumn(i)).getToType()));
166
+ column.getName(),
167
+ factory.newColumnGetter(column, columnOption).getToType()));
152
168
  }
153
169
  return new Schema(columns.build());
154
170
  }
@@ -220,7 +236,7 @@ public abstract class AbstractJdbcInputPlugin
220
236
  PageBuilder pageBuilder = new PageBuilder(allocator, schema, output);
221
237
 
222
238
  try {
223
- List<ColumnGetter> getters = newColumnGetters(task, querySchema);
239
+ List<ColumnGetter> getters = newColumnGetters(task, querySchema, pageBuilder);
224
240
 
225
241
  try (JdbcInputConnection con = newConnection(task)) {
226
242
  try (BatchSelect cursor = con.newSelectCursor(getQuery(task, con), task.getFetchRows())) {
@@ -248,16 +264,31 @@ public abstract class AbstractJdbcInputPlugin
248
264
  return report;
249
265
  }
250
266
 
251
- private List<ColumnGetter> newColumnGetters(PluginTask task, JdbcSchema querySchema) throws SQLException
267
+ private List<ColumnGetter> newColumnGetters(PluginTask task, JdbcSchema querySchema, PageBuilder pageBuilder)
268
+ throws SQLException
252
269
  {
253
- ColumnGetterFactory factory = newColumnGetterFactory(task);
270
+ ColumnGetterFactory factory = new ColumnGetterFactory(pageBuilder, task.getDefaultTimeZone());
254
271
  ImmutableList.Builder<ColumnGetter> getters = ImmutableList.builder();
255
272
  for (JdbcColumn c : querySchema.getColumns()) {
256
- getters.add(factory.newColumnGetter(c));
273
+ JdbcColumnOption columnOption = columnOptionOf(task.getColumnOptions(), c);
274
+ getters.add(factory.newColumnGetter(c, columnOption));
257
275
  }
258
276
  return getters.build();
259
277
  }
260
278
 
279
+ private static JdbcColumnOption columnOptionOf(Map<String, JdbcColumnOption> columnOptions, JdbcColumn targetColumn)
280
+ {
281
+ return Optional.fromNullable(columnOptions.get(targetColumn.getName())).or(
282
+ // default column option
283
+ new Supplier<JdbcColumnOption>()
284
+ {
285
+ public JdbcColumnOption get()
286
+ {
287
+ return Exec.newConfigSource().loadConfig(JdbcColumnOption.class);
288
+ }
289
+ });
290
+ }
291
+
261
292
  private boolean fetch(BatchSelect cursor,
262
293
  List<ColumnGetter> getters, PageBuilder pageBuilder) throws SQLException
263
294
  {
@@ -272,7 +303,7 @@ public abstract class AbstractJdbcInputPlugin
272
303
  do {
273
304
  for (int i=0; i < getters.size(); i++) {
274
305
  int index = i + 1; // JDBC column index begins from 1
275
- getters.get(i).getAndSet(result, index, pageBuilder, columns.get(i));
306
+ getters.get(i).getAndSet(result, index, columns.get(i));
276
307
  }
277
308
  pageBuilder.addRecord();
278
309
  rows++;
@@ -320,4 +351,11 @@ public abstract class AbstractJdbcInputPlugin
320
351
  // pages = ImmutableList.builder();
321
352
  // }
322
353
  //}
354
+
355
+ protected void loadDriverJar(String glob)
356
+ {
357
+ // TODO match glob
358
+ PluginClassLoader loader = (PluginClassLoader) getClass().getClassLoader();
359
+ loader.addPath(Paths.get(glob));
360
+ }
323
361
  }
@@ -9,16 +9,22 @@ public class JdbcColumn
9
9
  private String name;
10
10
  private String typeName;
11
11
  private int sqlType;
12
+ private int precision;
13
+ private int scale;
12
14
 
13
15
  @JsonCreator
14
16
  public JdbcColumn(
15
17
  @JsonProperty("name") String name,
16
18
  @JsonProperty("typeName") String typeName,
17
- @JsonProperty("sqlType") int sqlType)
19
+ @JsonProperty("sqlType") int sqlType,
20
+ @JsonProperty("precision") int precision,
21
+ @JsonProperty("scale") int scale)
18
22
  {
19
23
  this.name = name;
20
24
  this.typeName = typeName;
21
25
  this.sqlType = sqlType;
26
+ this.precision = precision;
27
+ this.scale = scale;
22
28
  }
23
29
 
24
30
  @JsonProperty("name")
@@ -38,4 +44,17 @@ public class JdbcColumn
38
44
  {
39
45
  return sqlType;
40
46
  }
47
+
48
+
49
+ @JsonProperty("precision")
50
+ public int getPrecision()
51
+ {
52
+ return precision;
53
+ }
54
+
55
+ @JsonProperty("scale")
56
+ public int getScale()
57
+ {
58
+ return scale;
59
+ }
41
60
  }
@@ -0,0 +1,36 @@
1
+ package org.embulk.input.jdbc;
2
+
3
+ import org.embulk.config.Config;
4
+ import org.embulk.config.ConfigDefault;
5
+ import org.embulk.config.ConfigInject;
6
+ import org.embulk.config.Task;
7
+ import org.embulk.spi.time.TimestampFormat;
8
+ import org.embulk.spi.type.Type;
9
+ import org.joda.time.DateTimeZone;
10
+ import org.jruby.embed.ScriptingContainer;
11
+
12
+ import com.google.common.base.Optional;
13
+
14
+ public interface JdbcColumnOption
15
+ extends Task
16
+ {
17
+ @Config("value_type")
18
+ @ConfigDefault("\"coalesce\"")
19
+ public String getValueType();
20
+
21
+ @Config("type")
22
+ @ConfigDefault("null")
23
+ public Optional<Type> getType();
24
+
25
+ @Config("timestamp_format")
26
+ @ConfigDefault("null")
27
+ public Optional<TimestampFormat> getTimestampFormat();
28
+
29
+ @Config("timezone")
30
+ @ConfigDefault("null")
31
+ public Optional<DateTimeZone> getTimeZone();
32
+
33
+ // required by TimestampFormatter
34
+ @ConfigInject
35
+ public ScriptingContainer getJRuby();
36
+ }
@@ -56,12 +56,12 @@ public class JdbcInputConnection
56
56
  ImmutableList.Builder<JdbcColumn> columns = ImmutableList.builder();
57
57
  for (int i=0; i < metadata.getColumnCount(); i++) {
58
58
  int index = i + 1; // JDBC column index begins from 1
59
- String name = metadata.getColumnName(index);
59
+ String name = metadata.getColumnLabel(index);
60
60
  String typeName = metadata.getColumnTypeName(index);
61
61
  int sqlType = metadata.getColumnType(index);
62
- //String scale = metadata.getScale(index)
63
- //String precision = metadata.getPrecision(index)
64
- columns.add(new JdbcColumn(name, typeName, sqlType));
62
+ int scale = metadata.getScale(index);
63
+ int precision = metadata.getPrecision(index);
64
+ columns.add(new JdbcColumn(name, typeName, sqlType, precision, scale));
65
65
  }
66
66
  return new JdbcSchema(columns.build());
67
67
  }
@@ -0,0 +1,76 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.sql.ResultSet;
4
+ import java.sql.SQLException;
5
+ import org.embulk.spi.Column;
6
+ import org.embulk.spi.ColumnVisitor;
7
+ import org.embulk.spi.PageBuilder;
8
+ import org.embulk.spi.type.Type;
9
+
10
+ public abstract class AbstractColumnGetter implements ColumnGetter, ColumnVisitor
11
+ {
12
+ protected final PageBuilder to;
13
+ private final Type toType;
14
+
15
+ public AbstractColumnGetter(PageBuilder to, Type toType)
16
+ {
17
+ this.to = to;
18
+ this.toType = toType;
19
+ }
20
+
21
+ @Override
22
+ public void getAndSet(ResultSet from, int fromIndex,
23
+ Column toColumn) throws SQLException {
24
+
25
+ fetch(from, fromIndex);
26
+ if (from.wasNull()) {
27
+ to.setNull(toColumn);
28
+ } else {
29
+ toColumn.visit(this);
30
+ }
31
+ }
32
+
33
+ protected abstract void fetch(ResultSet from, int fromIndex) throws SQLException;
34
+
35
+ @Override
36
+ public void booleanColumn(Column column)
37
+ {
38
+ to.setNull(column);
39
+ }
40
+
41
+ @Override
42
+ public void longColumn(Column column)
43
+ {
44
+ to.setNull(column);
45
+ }
46
+
47
+ @Override
48
+ public void doubleColumn(Column column)
49
+ {
50
+ to.setNull(column);
51
+ }
52
+
53
+ @Override
54
+ public void stringColumn(Column column)
55
+ {
56
+ to.setNull(column);
57
+ }
58
+
59
+ @Override
60
+ public void timestampColumn(Column column)
61
+ {
62
+ to.setNull(column);
63
+ }
64
+
65
+ @Override
66
+ public Type getToType()
67
+ {
68
+ if (toType == null) {
69
+ return getDefaultToType();
70
+ }
71
+ return toType;
72
+ }
73
+
74
+ protected abstract Type getDefaultToType();
75
+
76
+ }
@@ -0,0 +1,33 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import org.embulk.spi.Column;
4
+ import org.embulk.spi.PageBuilder;
5
+ import org.embulk.spi.time.Timestamp;
6
+ import org.embulk.spi.time.TimestampFormatter;
7
+ import org.embulk.spi.type.Type;
8
+
9
+ public abstract class AbstractTimestampColumnGetter
10
+ extends AbstractColumnGetter
11
+ {
12
+ private final TimestampFormatter timestampFormatter;
13
+ protected Timestamp value;
14
+
15
+ public AbstractTimestampColumnGetter(PageBuilder to, Type toType, TimestampFormatter timestampFormatter)
16
+ {
17
+ super(to, toType);
18
+
19
+ this.timestampFormatter = timestampFormatter;
20
+ }
21
+
22
+ @Override
23
+ public void stringColumn(Column column)
24
+ {
25
+ to.setString(column, timestampFormatter.format(value));
26
+ }
27
+
28
+ @Override
29
+ public void timestampColumn(Column column)
30
+ {
31
+ to.setTimestamp(column, value);
32
+ }
33
+ }
@@ -0,0 +1,59 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.math.BigDecimal;
4
+ import java.sql.ResultSet;
5
+ import java.sql.SQLException;
6
+ import org.embulk.spi.Column;
7
+ import org.embulk.spi.PageBuilder;
8
+ import org.embulk.spi.type.Type;
9
+ import org.embulk.spi.type.Types;
10
+
11
+ public class BigDecimalColumnGetter
12
+ extends AbstractColumnGetter
13
+ {
14
+ private BigDecimal value;
15
+
16
+ public BigDecimalColumnGetter(PageBuilder to, Type toType)
17
+ {
18
+ super(to, toType);
19
+ }
20
+
21
+ @Override
22
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
23
+ {
24
+ value = from.getBigDecimal(fromIndex);
25
+ }
26
+
27
+ @Override
28
+ protected Type getDefaultToType()
29
+ {
30
+ return Types.DOUBLE;
31
+ }
32
+
33
+ @Override
34
+ public void booleanColumn(Column column)
35
+ {
36
+ to.setBoolean(column, value.signum() > 0);
37
+ }
38
+
39
+ @Override
40
+ public void longColumn(Column column)
41
+ {
42
+ to.setLong(column, value.longValue());
43
+ }
44
+
45
+ @Override
46
+ public void doubleColumn(Column column)
47
+ {
48
+ // rounded value could be Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY.
49
+ double rounded = value.doubleValue();
50
+ to.setDouble(column, rounded);
51
+ }
52
+
53
+ @Override
54
+ public void stringColumn(Column column)
55
+ {
56
+ to.setString(column, value.toPlainString());
57
+ }
58
+
59
+ }
@@ -0,0 +1,56 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.sql.ResultSet;
4
+ import java.sql.SQLException;
5
+ import org.embulk.spi.Column;
6
+ import org.embulk.spi.PageBuilder;
7
+ import org.embulk.spi.type.Type;
8
+ import org.embulk.spi.type.Types;
9
+
10
+ public class BooleanColumnGetter
11
+ extends AbstractColumnGetter
12
+ {
13
+ private boolean value;
14
+
15
+ public BooleanColumnGetter(PageBuilder to, Type toType)
16
+ {
17
+ super(to, toType);
18
+ }
19
+
20
+ @Override
21
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
22
+ {
23
+ value = from.getBoolean(fromIndex);
24
+ }
25
+
26
+ @Override
27
+ protected Type getDefaultToType()
28
+ {
29
+ return Types.BOOLEAN;
30
+ }
31
+
32
+ @Override
33
+ public void booleanColumn(Column column)
34
+ {
35
+ to.setBoolean(column, value);
36
+ }
37
+
38
+ @Override
39
+ public void longColumn(Column column)
40
+ {
41
+ to.setLong(column, value ? 1L : 0L);
42
+ }
43
+
44
+ @Override
45
+ public void doubleColumn(Column column)
46
+ {
47
+ to.setDouble(column, value ? 1.0 : 0.0);
48
+ }
49
+
50
+ @Override
51
+ public void stringColumn(Column column)
52
+ {
53
+ to.setString(column, Boolean.toString(value));
54
+ }
55
+
56
+ }
@@ -3,13 +3,12 @@ package org.embulk.input.jdbc.getter;
3
3
  import java.sql.ResultSet;
4
4
  import java.sql.SQLException;
5
5
  import org.embulk.spi.Column;
6
- import org.embulk.spi.PageBuilder;
7
6
  import org.embulk.spi.type.Type;
8
7
 
9
8
  public interface ColumnGetter
10
9
  {
11
10
  public void getAndSet(ResultSet from, int fromIndex,
12
- PageBuilder to, Column toColumn) throws SQLException;
11
+ Column toColumn) throws SQLException;
13
12
 
14
13
  public Type getToType();
15
14
  }
@@ -1,38 +1,84 @@
1
1
  package org.embulk.input.jdbc.getter;
2
2
 
3
3
  import java.sql.Types;
4
+
5
+ import org.embulk.config.ConfigException;
4
6
  import org.embulk.input.jdbc.JdbcColumn;
5
- import org.embulk.input.jdbc.getter.ColumnGetters.BooleanColumnGetter;
6
- import org.embulk.input.jdbc.getter.ColumnGetters.LongColumnGetter;
7
- import org.embulk.input.jdbc.getter.ColumnGetters.DoubleColumnGetter;
8
- import org.embulk.input.jdbc.getter.ColumnGetters.StringColumnGetter;
9
- import org.embulk.input.jdbc.getter.ColumnGetters.DateColumnGetter;
10
- import org.embulk.input.jdbc.getter.ColumnGetters.TimeColumnGetter;
11
- import org.embulk.input.jdbc.getter.ColumnGetters.TimestampColumnGetter;
12
- import org.embulk.input.jdbc.getter.ColumnGetters.BigDecimalToDoubleColumnGetter;
7
+ import org.embulk.input.jdbc.JdbcColumnOption;
8
+ import org.embulk.spi.PageBuilder;
9
+ import org.embulk.spi.time.TimestampFormatter;
10
+ import org.embulk.spi.type.TimestampType;
11
+ import org.embulk.spi.type.Type;
12
+ import org.joda.time.DateTimeZone;
13
13
 
14
14
  public class ColumnGetterFactory
15
15
  {
16
- public ColumnGetter newColumnGetter(JdbcColumn column)
16
+ private final PageBuilder to;
17
+ private final DateTimeZone defaultTimeZone;
18
+
19
+ public ColumnGetterFactory(PageBuilder to, DateTimeZone defaultTimeZone)
20
+ {
21
+ this.to = to;
22
+ this.defaultTimeZone = defaultTimeZone;
23
+ }
24
+
25
+ public ColumnGetter newColumnGetter(JdbcColumn column, JdbcColumnOption option)
26
+ {
27
+ return newColumnGetter(column, option, option.getValueType());
28
+ }
29
+
30
+ private ColumnGetter newColumnGetter(JdbcColumn column, JdbcColumnOption option, String valueType)
31
+ {
32
+ Type toType = getToType(option);
33
+ switch(valueType) {
34
+ case "coalesce":
35
+ return newColumnGetter(column, option, sqlTypeToValueType(column, column.getSqlType()));
36
+ case "long":
37
+ return new LongColumnGetter(to, toType);
38
+ case "float":
39
+ return new FloatColumnGetter(to, toType);
40
+ case "double":
41
+ return new DoubleColumnGetter(to, toType);
42
+ case "boolean":
43
+ return new BooleanColumnGetter(to, toType);
44
+ case "string":
45
+ return new StringColumnGetter(to, toType);
46
+ case "date":
47
+ return new DateColumnGetter(to, toType, newTimestampFormatter(option, DateColumnGetter.DEFAULT_FORMAT));
48
+ case "time":
49
+ return new TimeColumnGetter(to, toType, newTimestampFormatter(option, DateColumnGetter.DEFAULT_FORMAT));
50
+ case "timestamp":
51
+ return new TimestampColumnGetter(to, toType, newTimestampFormatter(option, DateColumnGetter.DEFAULT_FORMAT));
52
+ case "decimal":
53
+ return new BigDecimalColumnGetter(to, toType);
54
+ default:
55
+ throw new ConfigException(String.format("Unknown value_type '%s' for column '%s'", option.getValueType(), column.getName()));
56
+ }
57
+ }
58
+
59
+ private String sqlTypeToValueType(JdbcColumn column, int sqlType)
17
60
  {
18
- switch(column.getSqlType()) {
61
+ switch(sqlType) {
19
62
  // getLong
20
63
  case Types.TINYINT:
21
64
  case Types.SMALLINT:
22
65
  case Types.INTEGER:
23
66
  case Types.BIGINT:
24
- return new LongColumnGetter();
67
+ return "long";
25
68
 
26
- // getDouble
27
- case Types.DOUBLE:
69
+ // getFloat
28
70
  case Types.FLOAT:
29
71
  case Types.REAL:
30
- return new DoubleColumnGetter();
72
+ return "float";
73
+
74
+ // getDouble
75
+ case Types.DOUBLE:
76
+ return "double";
31
77
 
32
78
  // getBool
33
79
  case Types.BOOLEAN:
34
80
  case Types.BIT: // JDBC BIT is boolean, unlike SQL-92
35
- return new BooleanColumnGetter();
81
+ return "boolean";
36
82
 
37
83
  // getString, Clob
38
84
  case Types.CHAR:
@@ -42,7 +88,7 @@ public class ColumnGetterFactory
42
88
  case Types.NCHAR:
43
89
  case Types.NVARCHAR:
44
90
  case Types.LONGNVARCHAR:
45
- return new StringColumnGetter();
91
+ return "string";
46
92
 
47
93
  // TODO
48
94
  //// getBytes Blob
@@ -54,15 +100,15 @@ public class ColumnGetterFactory
54
100
 
55
101
  // getDate
56
102
  case Types.DATE:
57
- return new DateColumnGetter(); // TODO
103
+ return "date";
58
104
 
59
105
  // getTime
60
106
  case Types.TIME:
61
- return new TimeColumnGetter(); // TODO
107
+ return "time";
62
108
 
63
109
  // getTimestamp
64
110
  case Types.TIMESTAMP:
65
- return new TimestampColumnGetter();
111
+ return "timestamp";
66
112
 
67
113
  // TODO
68
114
  //// Null
@@ -72,7 +118,7 @@ public class ColumnGetterFactory
72
118
  // getBigDecimal
73
119
  case Types.NUMERIC:
74
120
  case Types.DECIMAL:
75
- return new BigDecimalToDoubleColumnGetter();
121
+ return "decimal";
76
122
 
77
123
  // others
78
124
  case Types.ARRAY: // array
@@ -89,6 +135,26 @@ public class ColumnGetterFactory
89
135
  }
90
136
  }
91
137
 
138
+ private Type getToType(JdbcColumnOption option)
139
+ {
140
+ if (!option.getType().isPresent()) {
141
+ return null;
142
+ }
143
+ Type toType = option.getType().get();
144
+ if (toType instanceof TimestampType && option.getTimestampFormat().isPresent()) {
145
+ toType = ((TimestampType)toType).withFormat(option.getTimestampFormat().get().getFormat());
146
+ }
147
+ return toType;
148
+ }
149
+
150
+ private TimestampFormatter newTimestampFormatter(JdbcColumnOption option, String defaultTimestampFormat)
151
+ {
152
+ return new TimestampFormatter(
153
+ option.getJRuby(),
154
+ option.getTimestampFormat().isPresent() ? option.getTimestampFormat().get().getFormat() : defaultTimestampFormat,
155
+ option.getTimeZone().or(defaultTimeZone));
156
+ }
157
+
92
158
  private static UnsupportedOperationException unsupportedOperationException(JdbcColumn column)
93
159
  {
94
160
  throw new UnsupportedOperationException(
@@ -0,0 +1,37 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.sql.Date;
4
+ import java.sql.ResultSet;
5
+ import java.sql.SQLException;
6
+ import org.embulk.spi.PageBuilder;
7
+ import org.embulk.spi.time.Timestamp;
8
+ import org.embulk.spi.time.TimestampFormatter;
9
+ import org.embulk.spi.type.Type;
10
+ import org.embulk.spi.type.Types;
11
+
12
+ public class DateColumnGetter
13
+ extends AbstractTimestampColumnGetter
14
+ {
15
+ static final String DEFAULT_FORMAT = "%Y-%m-%d";
16
+
17
+ public DateColumnGetter(PageBuilder to, Type toType, TimestampFormatter timestampFormatter)
18
+ {
19
+ super(to, toType, timestampFormatter);
20
+ }
21
+
22
+ @Override
23
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
24
+ {
25
+ Date date = from.getDate(fromIndex);
26
+ if (date != null) {
27
+ value = Timestamp.ofEpochMilli(date.getTime());
28
+ }
29
+ }
30
+
31
+ @Override
32
+ protected Type getDefaultToType()
33
+ {
34
+ return Types.TIMESTAMP.withFormat(DEFAULT_FORMAT);
35
+ }
36
+
37
+ }
@@ -0,0 +1,66 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.math.RoundingMode;
4
+ import java.sql.ResultSet;
5
+ import java.sql.SQLException;
6
+ import org.embulk.spi.Column;
7
+ import org.embulk.spi.PageBuilder;
8
+ import org.embulk.spi.type.Type;
9
+ import org.embulk.spi.type.Types;
10
+ import com.google.common.math.DoubleMath;
11
+
12
+ public class DoubleColumnGetter
13
+ extends AbstractColumnGetter
14
+ {
15
+ private double value;
16
+
17
+ public DoubleColumnGetter(PageBuilder to, Type toType)
18
+ {
19
+ super(to, toType);
20
+ }
21
+
22
+ @Override
23
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
24
+ {
25
+ value = from.getDouble(fromIndex);
26
+ }
27
+
28
+ @Override
29
+ protected Type getDefaultToType()
30
+ {
31
+ return Types.DOUBLE;
32
+ }
33
+
34
+ @Override
35
+ public void booleanColumn(Column column)
36
+ {
37
+ to.setBoolean(column, value > 0.0);
38
+ }
39
+
40
+ @Override
41
+ public void longColumn(Column column)
42
+ {
43
+ long l;
44
+ try {
45
+ // TODO configurable rounding mode
46
+ l = DoubleMath.roundToLong(value, RoundingMode.HALF_UP);
47
+ } catch (ArithmeticException e) {
48
+ // NaN / Infinite / -Infinite
49
+ super.longColumn(column);
50
+ return;
51
+ }
52
+ to.setLong(column, l);
53
+ }
54
+
55
+ @Override
56
+ public void doubleColumn(Column column)
57
+ {
58
+ to.setDouble(column, value);
59
+ }
60
+
61
+ @Override
62
+ public void stringColumn(Column column)
63
+ {
64
+ to.setString(column, Double.toString(value));
65
+ }
66
+ }
@@ -0,0 +1,66 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.math.RoundingMode;
4
+ import java.sql.ResultSet;
5
+ import java.sql.SQLException;
6
+ import org.embulk.spi.Column;
7
+ import org.embulk.spi.PageBuilder;
8
+ import org.embulk.spi.type.Type;
9
+ import org.embulk.spi.type.Types;
10
+ import com.google.common.math.DoubleMath;
11
+
12
+ public class FloatColumnGetter
13
+ extends AbstractColumnGetter
14
+ {
15
+ private float value;
16
+
17
+ public FloatColumnGetter(PageBuilder to, Type toType)
18
+ {
19
+ super(to, toType);
20
+ }
21
+
22
+ @Override
23
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
24
+ {
25
+ value = from.getFloat(fromIndex);
26
+ }
27
+
28
+ @Override
29
+ protected Type getDefaultToType()
30
+ {
31
+ return Types.DOUBLE;
32
+ }
33
+
34
+ @Override
35
+ public void booleanColumn(Column column)
36
+ {
37
+ to.setBoolean(column, value > 0.0);
38
+ }
39
+
40
+ @Override
41
+ public void longColumn(Column column)
42
+ {
43
+ long l;
44
+ try {
45
+ // TODO configurable rounding mode
46
+ l = DoubleMath.roundToLong(value, RoundingMode.HALF_UP);
47
+ } catch (ArithmeticException e) {
48
+ // NaN / Infinite / -Infinite
49
+ super.longColumn(column);
50
+ return;
51
+ }
52
+ to.setLong(column, l);
53
+ }
54
+
55
+ @Override
56
+ public void doubleColumn(Column column)
57
+ {
58
+ to.setDouble(column, value);
59
+ }
60
+
61
+ @Override
62
+ public void stringColumn(Column column)
63
+ {
64
+ to.setString(column, Float.toString(value));
65
+ }
66
+ }
@@ -0,0 +1,56 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.sql.ResultSet;
4
+ import java.sql.SQLException;
5
+ import org.embulk.spi.Column;
6
+ import org.embulk.spi.PageBuilder;
7
+ import org.embulk.spi.type.Type;
8
+ import org.embulk.spi.type.Types;
9
+
10
+ public class LongColumnGetter
11
+ extends AbstractColumnGetter
12
+ {
13
+ private long value;
14
+
15
+ public LongColumnGetter(PageBuilder to, Type toType)
16
+ {
17
+ super(to, toType);
18
+ }
19
+
20
+ @Override
21
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
22
+ {
23
+ value = from.getLong(fromIndex);
24
+ }
25
+
26
+ @Override
27
+ protected Type getDefaultToType()
28
+ {
29
+ return Types.LONG;
30
+ }
31
+
32
+ @Override
33
+ public void booleanColumn(Column column)
34
+ {
35
+ to.setBoolean(column, value > 0L);
36
+ }
37
+
38
+ @Override
39
+ public void longColumn(Column column)
40
+ {
41
+ to.setLong(column, value);
42
+ }
43
+
44
+ @Override
45
+ public void doubleColumn(Column column)
46
+ {
47
+ to.setDouble(column, value);
48
+ }
49
+
50
+ @Override
51
+ public void stringColumn(Column column)
52
+ {
53
+ to.setString(column, Long.toString(value));
54
+ }
55
+
56
+ }
@@ -0,0 +1,64 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.sql.ResultSet;
4
+ import java.sql.SQLException;
5
+ import org.embulk.spi.Column;
6
+ import org.embulk.spi.PageBuilder;
7
+ import org.embulk.spi.type.Type;
8
+ import org.embulk.spi.type.Types;
9
+
10
+ public class StringColumnGetter
11
+ extends AbstractColumnGetter
12
+ {
13
+ private String value;
14
+
15
+ public StringColumnGetter(PageBuilder to, Type toType)
16
+ {
17
+ super(to, toType);
18
+ }
19
+
20
+ @Override
21
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
22
+ {
23
+ value = from.getString(fromIndex);
24
+ }
25
+
26
+ @Override
27
+ protected Type getDefaultToType()
28
+ {
29
+ return Types.STRING;
30
+ }
31
+
32
+ @Override
33
+ public void longColumn(Column column)
34
+ {
35
+ long l;
36
+ try {
37
+ l = Long.parseLong(value);
38
+ } catch (NumberFormatException e) {
39
+ super.longColumn(column);
40
+ return;
41
+ }
42
+ to.setLong(column, l);
43
+ }
44
+
45
+ @Override
46
+ public void doubleColumn(Column column)
47
+ {
48
+ double d;
49
+ try {
50
+ d = Double.parseDouble(value);
51
+ } catch (NumberFormatException e) {
52
+ super.doubleColumn(column);
53
+ return;
54
+ }
55
+ to.setDouble(column, d);
56
+ }
57
+
58
+ @Override
59
+ public void stringColumn(Column column)
60
+ {
61
+ to.setString(column, value);
62
+ }
63
+
64
+ }
@@ -0,0 +1,37 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.sql.ResultSet;
4
+ import java.sql.SQLException;
5
+ import java.sql.Time;
6
+ import org.embulk.spi.PageBuilder;
7
+ import org.embulk.spi.time.Timestamp;
8
+ import org.embulk.spi.time.TimestampFormatter;
9
+ import org.embulk.spi.type.Type;
10
+ import org.embulk.spi.type.Types;
11
+
12
+ public class TimeColumnGetter
13
+ extends AbstractTimestampColumnGetter
14
+ {
15
+ static final String DEFAULT_FORMAT = "%H:%M:%S";
16
+
17
+ public TimeColumnGetter(PageBuilder to, Type toType, TimestampFormatter timestampFormatter)
18
+ {
19
+ super(to, toType, timestampFormatter);
20
+ }
21
+
22
+ @Override
23
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
24
+ {
25
+ Time time = from.getTime(fromIndex);
26
+ if (time != null) {
27
+ value = Timestamp.ofEpochMilli(time.getTime());
28
+ }
29
+ }
30
+
31
+ @Override
32
+ protected Type getDefaultToType()
33
+ {
34
+ return Types.TIMESTAMP.withFormat(DEFAULT_FORMAT);
35
+ }
36
+
37
+ }
@@ -0,0 +1,36 @@
1
+ package org.embulk.input.jdbc.getter;
2
+
3
+ import java.sql.ResultSet;
4
+ import java.sql.SQLException;
5
+ import org.embulk.spi.PageBuilder;
6
+ import org.embulk.spi.time.Timestamp;
7
+ import org.embulk.spi.time.TimestampFormatter;
8
+ import org.embulk.spi.type.Type;
9
+ import org.embulk.spi.type.Types;
10
+
11
+ public class TimestampColumnGetter
12
+ extends AbstractTimestampColumnGetter
13
+ {
14
+ static final String DEFAULT_FORMAT = "%Y-%m-%d %H:%M:%S";
15
+
16
+ public TimestampColumnGetter(PageBuilder to, Type toType, TimestampFormatter timestampFormatter)
17
+ {
18
+ super(to, toType, timestampFormatter);
19
+ }
20
+
21
+ @Override
22
+ protected void fetch(ResultSet from, int fromIndex) throws SQLException
23
+ {
24
+ java.sql.Timestamp timestamp = from.getTimestamp(fromIndex);
25
+ if (timestamp != null) {
26
+ value = Timestamp.ofEpochSecond(timestamp.getTime() / 1000, timestamp.getNanos());
27
+ }
28
+ }
29
+
30
+ @Override
31
+ protected Type getDefaultToType()
32
+ {
33
+ return Types.TIMESTAMP.withFormat(DEFAULT_FORMAT);
34
+ }
35
+
36
+ }
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-06-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selects records from a table.
14
14
  email:
@@ -22,12 +22,23 @@ files:
22
22
  - src/main/java/org/embulk/input/JdbcInputPlugin.java
23
23
  - src/main/java/org/embulk/input/jdbc/AbstractJdbcInputPlugin.java
24
24
  - src/main/java/org/embulk/input/jdbc/JdbcColumn.java
25
+ - src/main/java/org/embulk/input/jdbc/JdbcColumnOption.java
25
26
  - src/main/java/org/embulk/input/jdbc/JdbcInputConnection.java
26
27
  - src/main/java/org/embulk/input/jdbc/JdbcSchema.java
28
+ - src/main/java/org/embulk/input/jdbc/getter/AbstractColumnGetter.java
29
+ - src/main/java/org/embulk/input/jdbc/getter/AbstractTimestampColumnGetter.java
30
+ - src/main/java/org/embulk/input/jdbc/getter/BigDecimalColumnGetter.java
31
+ - src/main/java/org/embulk/input/jdbc/getter/BooleanColumnGetter.java
27
32
  - src/main/java/org/embulk/input/jdbc/getter/ColumnGetter.java
28
33
  - src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java
29
- - src/main/java/org/embulk/input/jdbc/getter/ColumnGetters.java
30
- - classpath/embulk-input-jdbc-0.4.0.jar
34
+ - src/main/java/org/embulk/input/jdbc/getter/DateColumnGetter.java
35
+ - src/main/java/org/embulk/input/jdbc/getter/DoubleColumnGetter.java
36
+ - src/main/java/org/embulk/input/jdbc/getter/FloatColumnGetter.java
37
+ - src/main/java/org/embulk/input/jdbc/getter/LongColumnGetter.java
38
+ - src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java
39
+ - src/main/java/org/embulk/input/jdbc/getter/TimeColumnGetter.java
40
+ - src/main/java/org/embulk/input/jdbc/getter/TimestampColumnGetter.java
41
+ - classpath/embulk-input-jdbc-0.5.0.jar
31
42
  homepage: https://github.com/embulk/embulk-input-jdbc
32
43
  licenses:
33
44
  - Apache 2.0
Binary file
@@ -1,197 +0,0 @@
1
- package org.embulk.input.jdbc.getter;
2
-
3
- import java.sql.ResultSet;
4
- import java.sql.SQLException;
5
- import java.math.BigDecimal;
6
- import org.embulk.spi.Column;
7
- import org.embulk.spi.PageBuilder;
8
- import org.embulk.spi.Column;
9
- import org.embulk.spi.time.Timestamp;
10
- import org.embulk.spi.type.Type;
11
- import org.embulk.spi.type.Types;
12
-
13
- public class ColumnGetters
14
- {
15
- private ColumnGetters() { }
16
-
17
- public static class BooleanColumnGetter
18
- implements ColumnGetter
19
- {
20
- @Override
21
- public void getAndSet(ResultSet from, int fromIndex,
22
- PageBuilder to, Column toColumn) throws SQLException
23
- {
24
- boolean v = from.getBoolean(fromIndex);
25
- if (from.wasNull()) {
26
- to.setNull(toColumn);
27
- } else {
28
- to.setBoolean(toColumn, v);
29
- }
30
- }
31
-
32
- @Override
33
- public Type getToType()
34
- {
35
- return Types.BOOLEAN;
36
- }
37
- }
38
-
39
- public static class LongColumnGetter
40
- implements ColumnGetter
41
- {
42
- @Override
43
- public void getAndSet(ResultSet from, int fromIndex,
44
- PageBuilder to, Column toColumn) throws SQLException
45
- {
46
- long v = from.getLong(fromIndex);
47
- if (from.wasNull()) {
48
- to.setNull(toColumn);
49
- } else {
50
- to.setLong(toColumn, v);
51
- }
52
- }
53
-
54
- @Override
55
- public Type getToType()
56
- {
57
- return Types.LONG;
58
- }
59
- }
60
-
61
- public static class DoubleColumnGetter
62
- implements ColumnGetter
63
- {
64
- @Override
65
- public void getAndSet(ResultSet from, int fromIndex,
66
- PageBuilder to, Column toColumn) throws SQLException
67
- {
68
- double v = from.getDouble(fromIndex);
69
- if (from.wasNull()) {
70
- to.setNull(toColumn);
71
- } else {
72
- to.setDouble(toColumn, v);
73
- }
74
- }
75
-
76
- @Override
77
- public Type getToType()
78
- {
79
- return Types.DOUBLE;
80
- }
81
- }
82
-
83
- public static class StringColumnGetter
84
- implements ColumnGetter
85
- {
86
- @Override
87
- public void getAndSet(ResultSet from, int fromIndex,
88
- PageBuilder to, Column toColumn) throws SQLException
89
- {
90
- String v = from.getString(fromIndex);
91
- if (from.wasNull()) {
92
- to.setNull(toColumn);
93
- } else {
94
- to.setString(toColumn, v);
95
- }
96
- }
97
-
98
- @Override
99
- public Type getToType()
100
- {
101
- return Types.STRING;
102
- }
103
- }
104
-
105
- public static class DateColumnGetter
106
- implements ColumnGetter
107
- {
108
- @Override
109
- public void getAndSet(ResultSet from, int fromIndex,
110
- PageBuilder to, Column toColumn) throws SQLException
111
- {
112
- java.sql.Date v = from.getDate(fromIndex);
113
- if (from.wasNull()) {
114
- to.setNull(toColumn);
115
- } else {
116
- Timestamp t = Timestamp.ofEpochMilli(v.getTime());
117
- to.setTimestamp(toColumn, t);
118
- }
119
- }
120
-
121
- @Override
122
- public Type getToType()
123
- {
124
- return Types.TIMESTAMP.withFormat("%Y-%m-%d");
125
- }
126
- }
127
-
128
- public static class TimeColumnGetter
129
- implements ColumnGetter
130
- {
131
- @Override
132
- public void getAndSet(ResultSet from, int fromIndex,
133
- PageBuilder to, Column toColumn) throws SQLException
134
- {
135
- java.sql.Time v = from.getTime(fromIndex);
136
- if (from.wasNull()) {
137
- to.setNull(toColumn);
138
- } else {
139
- Timestamp t = Timestamp.ofEpochMilli(v.getTime());
140
- to.setTimestamp(toColumn, t);
141
- }
142
- }
143
-
144
- @Override
145
- public Type getToType()
146
- {
147
- return Types.TIMESTAMP.withFormat("%H:%M:%S");
148
- }
149
- }
150
-
151
- public static class TimestampColumnGetter
152
- implements ColumnGetter
153
- {
154
- @Override
155
- public void getAndSet(ResultSet from, int fromIndex,
156
- PageBuilder to, Column toColumn) throws SQLException
157
- {
158
- java.sql.Timestamp v = from.getTimestamp(fromIndex);
159
- if (from.wasNull()) {
160
- to.setNull(toColumn);
161
- } else {
162
- Timestamp t = Timestamp.ofEpochSecond(v.getTime() / 1000, v.getNanos());
163
- to.setTimestamp(toColumn, t);
164
- }
165
- }
166
-
167
- @Override
168
- public Type getToType()
169
- {
170
- return Types.TIMESTAMP.withFormat("%Y-%m-%d %H:%M:%S");
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
- }
197
- }