embulk-input-athena 0.1.0 → 0.1.1
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 +4 -4
- data/.gitignore +2 -1
- data/build.gradle +7 -3
- data/src/main/java/org/embulk/input/athena/AthenaInputConnection.java +1 -0
- metadata +4 -28
- data/src/main/java/org/embulk/input/jdbc/AbstractJdbcInputPlugin.java +0 -674
- data/src/main/java/org/embulk/input/jdbc/JdbcColumn.java +0 -58
- data/src/main/java/org/embulk/input/jdbc/JdbcColumnOption.java +0 -31
- data/src/main/java/org/embulk/input/jdbc/JdbcInputConnection.java +0 -397
- data/src/main/java/org/embulk/input/jdbc/JdbcLiteral.java +0 -38
- data/src/main/java/org/embulk/input/jdbc/JdbcSchema.java +0 -55
- data/src/main/java/org/embulk/input/jdbc/Ssl.java +0 -37
- data/src/main/java/org/embulk/input/jdbc/ToString.java +0 -54
- data/src/main/java/org/embulk/input/jdbc/ToStringMap.java +0 -35
- data/src/main/java/org/embulk/input/jdbc/getter/AbstractColumnGetter.java +0 -105
- data/src/main/java/org/embulk/input/jdbc/getter/AbstractIncrementalHandler.java +0 -45
- data/src/main/java/org/embulk/input/jdbc/getter/AbstractTimestampColumnGetter.java +0 -38
- data/src/main/java/org/embulk/input/jdbc/getter/BigDecimalColumnGetter.java +0 -59
- data/src/main/java/org/embulk/input/jdbc/getter/BooleanColumnGetter.java +0 -56
- data/src/main/java/org/embulk/input/jdbc/getter/ColumnGetter.java +0 -21
- data/src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java +0 -207
- data/src/main/java/org/embulk/input/jdbc/getter/DateColumnGetter.java +0 -37
- data/src/main/java/org/embulk/input/jdbc/getter/DoubleColumnGetter.java +0 -66
- data/src/main/java/org/embulk/input/jdbc/getter/FloatColumnGetter.java +0 -66
- data/src/main/java/org/embulk/input/jdbc/getter/JsonColumnGetter.java +0 -57
- data/src/main/java/org/embulk/input/jdbc/getter/LongColumnGetter.java +0 -70
- data/src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java +0 -96
- data/src/main/java/org/embulk/input/jdbc/getter/TimeColumnGetter.java +0 -37
- data/src/main/java/org/embulk/input/jdbc/getter/TimestampColumnGetter.java +0 -36
- data/src/main/java/org/embulk/input/jdbc/getter/TimestampWithTimeZoneIncrementalHandler.java +0 -83
- data/src/main/java/org/embulk/input/jdbc/getter/TimestampWithoutTimeZoneIncrementalHandler.java +0 -75
@@ -1,57 +0,0 @@
|
|
1
|
-
package org.embulk.input.jdbc.getter;
|
2
|
-
|
3
|
-
import java.sql.ResultSet;
|
4
|
-
import java.sql.SQLException;
|
5
|
-
|
6
|
-
import org.embulk.input.jdbc.getter.AbstractColumnGetter;
|
7
|
-
import org.embulk.spi.Column;
|
8
|
-
import org.embulk.spi.PageBuilder;
|
9
|
-
import org.embulk.spi.json.JsonParseException;
|
10
|
-
import org.embulk.spi.json.JsonParser;
|
11
|
-
import org.embulk.spi.type.Type;
|
12
|
-
import org.embulk.spi.type.Types;
|
13
|
-
import org.msgpack.value.Value;
|
14
|
-
|
15
|
-
public class JsonColumnGetter
|
16
|
-
extends AbstractColumnGetter
|
17
|
-
{
|
18
|
-
protected final JsonParser jsonParser = new JsonParser();
|
19
|
-
|
20
|
-
protected String value;
|
21
|
-
|
22
|
-
public JsonColumnGetter(PageBuilder to, Type toType)
|
23
|
-
{
|
24
|
-
super(to, toType);
|
25
|
-
}
|
26
|
-
|
27
|
-
@Override
|
28
|
-
protected void fetch(ResultSet from, int fromIndex) throws SQLException
|
29
|
-
{
|
30
|
-
value = from.getString(fromIndex);
|
31
|
-
}
|
32
|
-
|
33
|
-
@Override
|
34
|
-
protected Type getDefaultToType()
|
35
|
-
{
|
36
|
-
return Types.JSON;
|
37
|
-
}
|
38
|
-
|
39
|
-
@Override
|
40
|
-
public void jsonColumn(Column column)
|
41
|
-
{
|
42
|
-
Value v;
|
43
|
-
try {
|
44
|
-
v = jsonParser.parse(value);
|
45
|
-
} catch (JsonParseException e) {
|
46
|
-
super.jsonColumn(column);
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
to.setJson(column, v);
|
50
|
-
}
|
51
|
-
|
52
|
-
@Override
|
53
|
-
public void stringColumn(Column column)
|
54
|
-
{
|
55
|
-
to.setString(column, value);
|
56
|
-
}
|
57
|
-
}
|
@@ -1,70 +0,0 @@
|
|
1
|
-
package org.embulk.input.jdbc.getter;
|
2
|
-
|
3
|
-
import java.sql.ResultSet;
|
4
|
-
import java.sql.PreparedStatement;
|
5
|
-
import java.sql.SQLException;
|
6
|
-
import com.fasterxml.jackson.databind.JsonNode;
|
7
|
-
import org.embulk.spi.Column;
|
8
|
-
import org.embulk.spi.PageBuilder;
|
9
|
-
import org.embulk.spi.type.Type;
|
10
|
-
import org.embulk.spi.type.Types;
|
11
|
-
|
12
|
-
public class LongColumnGetter
|
13
|
-
extends AbstractColumnGetter
|
14
|
-
{
|
15
|
-
protected long value;
|
16
|
-
|
17
|
-
public LongColumnGetter(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.getLong(fromIndex);
|
26
|
-
}
|
27
|
-
|
28
|
-
@Override
|
29
|
-
protected Type getDefaultToType()
|
30
|
-
{
|
31
|
-
return Types.LONG;
|
32
|
-
}
|
33
|
-
|
34
|
-
@Override
|
35
|
-
public void booleanColumn(Column column)
|
36
|
-
{
|
37
|
-
to.setBoolean(column, value > 0L);
|
38
|
-
}
|
39
|
-
|
40
|
-
@Override
|
41
|
-
public void longColumn(Column column)
|
42
|
-
{
|
43
|
-
to.setLong(column, value);
|
44
|
-
}
|
45
|
-
|
46
|
-
@Override
|
47
|
-
public void doubleColumn(Column column)
|
48
|
-
{
|
49
|
-
to.setDouble(column, value);
|
50
|
-
}
|
51
|
-
|
52
|
-
@Override
|
53
|
-
public void stringColumn(Column column)
|
54
|
-
{
|
55
|
-
to.setString(column, Long.toString(value));
|
56
|
-
}
|
57
|
-
|
58
|
-
@Override
|
59
|
-
public JsonNode encodeToJson()
|
60
|
-
{
|
61
|
-
return jsonNodeFactory.numberNode(value);
|
62
|
-
}
|
63
|
-
|
64
|
-
@Override
|
65
|
-
public void decodeFromJsonTo(PreparedStatement toStatement, int toIndex, JsonNode fromValue)
|
66
|
-
throws SQLException
|
67
|
-
{
|
68
|
-
toStatement.setLong(toIndex, fromValue.asLong());
|
69
|
-
}
|
70
|
-
}
|
@@ -1,96 +0,0 @@
|
|
1
|
-
package org.embulk.input.jdbc.getter;
|
2
|
-
|
3
|
-
import java.sql.ResultSet;
|
4
|
-
import java.sql.PreparedStatement;
|
5
|
-
import java.sql.SQLException;
|
6
|
-
import com.fasterxml.jackson.databind.JsonNode;
|
7
|
-
import org.embulk.spi.Column;
|
8
|
-
import org.embulk.spi.PageBuilder;
|
9
|
-
import org.embulk.spi.json.JsonParseException;
|
10
|
-
import org.embulk.spi.json.JsonParser;
|
11
|
-
import org.embulk.spi.type.Type;
|
12
|
-
import org.embulk.spi.type.Types;
|
13
|
-
import org.msgpack.value.Value;
|
14
|
-
|
15
|
-
public class StringColumnGetter
|
16
|
-
extends AbstractColumnGetter
|
17
|
-
{
|
18
|
-
protected final JsonParser jsonParser = new JsonParser();
|
19
|
-
|
20
|
-
protected String value;
|
21
|
-
|
22
|
-
public StringColumnGetter(PageBuilder to, Type toType)
|
23
|
-
{
|
24
|
-
super(to, toType);
|
25
|
-
}
|
26
|
-
|
27
|
-
@Override
|
28
|
-
protected void fetch(ResultSet from, int fromIndex) throws SQLException
|
29
|
-
{
|
30
|
-
value = from.getString(fromIndex);
|
31
|
-
}
|
32
|
-
|
33
|
-
@Override
|
34
|
-
protected Type getDefaultToType()
|
35
|
-
{
|
36
|
-
return Types.STRING;
|
37
|
-
}
|
38
|
-
|
39
|
-
@Override
|
40
|
-
public void longColumn(Column column)
|
41
|
-
{
|
42
|
-
long l;
|
43
|
-
try {
|
44
|
-
l = Long.parseLong(value);
|
45
|
-
} catch (NumberFormatException e) {
|
46
|
-
super.longColumn(column);
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
to.setLong(column, l);
|
50
|
-
}
|
51
|
-
|
52
|
-
@Override
|
53
|
-
public void doubleColumn(Column column)
|
54
|
-
{
|
55
|
-
double d;
|
56
|
-
try {
|
57
|
-
d = Double.parseDouble(value);
|
58
|
-
} catch (NumberFormatException e) {
|
59
|
-
super.doubleColumn(column);
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
to.setDouble(column, d);
|
63
|
-
}
|
64
|
-
|
65
|
-
@Override
|
66
|
-
public void jsonColumn(Column column)
|
67
|
-
{
|
68
|
-
Value v;
|
69
|
-
try {
|
70
|
-
v = jsonParser.parse(value);
|
71
|
-
} catch (JsonParseException e) {
|
72
|
-
super.jsonColumn(column);
|
73
|
-
return;
|
74
|
-
}
|
75
|
-
to.setJson(column, v);
|
76
|
-
}
|
77
|
-
|
78
|
-
@Override
|
79
|
-
public void stringColumn(Column column)
|
80
|
-
{
|
81
|
-
to.setString(column, value);
|
82
|
-
}
|
83
|
-
|
84
|
-
@Override
|
85
|
-
public JsonNode encodeToJson()
|
86
|
-
{
|
87
|
-
return jsonNodeFactory.textNode(value);
|
88
|
-
}
|
89
|
-
|
90
|
-
@Override
|
91
|
-
public void decodeFromJsonTo(PreparedStatement toStatement, int toIndex, JsonNode fromValue)
|
92
|
-
throws SQLException
|
93
|
-
{
|
94
|
-
toStatement.setString(toIndex, fromValue.asText());
|
95
|
-
}
|
96
|
-
}
|
@@ -1,37 +0,0 @@
|
|
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
|
-
}
|
@@ -1,36 +0,0 @@
|
|
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
|
-
}
|
data/src/main/java/org/embulk/input/jdbc/getter/TimestampWithTimeZoneIncrementalHandler.java
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
package org.embulk.input.jdbc.getter;
|
2
|
-
|
3
|
-
import com.fasterxml.jackson.databind.JsonNode;
|
4
|
-
import com.google.common.base.Optional;
|
5
|
-
import java.sql.PreparedStatement;
|
6
|
-
import java.sql.ResultSet;
|
7
|
-
import java.sql.SQLException;
|
8
|
-
import java.sql.Timestamp;
|
9
|
-
import org.embulk.config.ConfigSource;
|
10
|
-
import org.embulk.config.Task;
|
11
|
-
import org.embulk.spi.Column;
|
12
|
-
import org.embulk.spi.Exec;
|
13
|
-
import org.embulk.spi.time.TimestampFormatter;
|
14
|
-
import org.embulk.spi.time.TimestampParser;
|
15
|
-
|
16
|
-
public class TimestampWithTimeZoneIncrementalHandler
|
17
|
-
extends AbstractIncrementalHandler
|
18
|
-
{
|
19
|
-
private static final String ISO_USEC_FORMAT = "%Y-%m-%dT%H:%M:%S.%6NZ";
|
20
|
-
private static final String ISO_USEC_PATTERN = "%Y-%m-%dT%H:%M:%S.%N%z";
|
21
|
-
|
22
|
-
private long epochSecond;
|
23
|
-
private int nano;
|
24
|
-
|
25
|
-
public TimestampWithTimeZoneIncrementalHandler(ColumnGetter next)
|
26
|
-
{
|
27
|
-
super(next);
|
28
|
-
}
|
29
|
-
|
30
|
-
@Override
|
31
|
-
public void getAndSet(ResultSet from, int fromIndex,
|
32
|
-
Column toColumn) throws SQLException
|
33
|
-
{
|
34
|
-
// sniff the value
|
35
|
-
Timestamp timestamp = from.getTimestamp(fromIndex);
|
36
|
-
if (timestamp != null) {
|
37
|
-
epochSecond = timestamp.getTime() / 1000;
|
38
|
-
nano = timestamp.getNanos();
|
39
|
-
}
|
40
|
-
|
41
|
-
super.getAndSet(from, fromIndex, toColumn);
|
42
|
-
}
|
43
|
-
|
44
|
-
private static interface FormatterIntlTask extends Task, TimestampFormatter.Task {}
|
45
|
-
private static interface FormatterIntlColumnOption extends Task, TimestampFormatter.TimestampColumnOption {}
|
46
|
-
|
47
|
-
@Override
|
48
|
-
public JsonNode encodeToJson()
|
49
|
-
{
|
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)));
|
58
|
-
String text = formatter.format(org.embulk.spi.time.Timestamp.ofEpochSecond(epochSecond, nano));
|
59
|
-
return jsonNodeFactory.textNode(text);
|
60
|
-
}
|
61
|
-
|
62
|
-
private static interface ParserIntlTask extends Task, TimestampParser.Task {}
|
63
|
-
private static interface ParserIntlColumnOption extends Task, TimestampParser.TimestampColumnOption {}
|
64
|
-
|
65
|
-
@Override
|
66
|
-
public void decodeFromJsonTo(PreparedStatement toStatement, int toIndex, JsonNode fromValue)
|
67
|
-
throws SQLException
|
68
|
-
{
|
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));
|
77
|
-
org.embulk.spi.time.Timestamp epoch = parser.parse(fromValue.asText());
|
78
|
-
|
79
|
-
Timestamp sqlTimestamp = new Timestamp(epoch.getEpochSecond() * 1000);
|
80
|
-
sqlTimestamp.setNanos(epoch.getNano());
|
81
|
-
toStatement.setTimestamp(toIndex, sqlTimestamp);
|
82
|
-
}
|
83
|
-
}
|
data/src/main/java/org/embulk/input/jdbc/getter/TimestampWithoutTimeZoneIncrementalHandler.java
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
package org.embulk.input.jdbc.getter;
|
2
|
-
|
3
|
-
import com.fasterxml.jackson.databind.JsonNode;
|
4
|
-
import java.sql.PreparedStatement;
|
5
|
-
import java.sql.ResultSet;
|
6
|
-
import java.sql.SQLException;
|
7
|
-
import java.sql.Timestamp;
|
8
|
-
import java.util.Calendar;
|
9
|
-
import java.util.TimeZone;
|
10
|
-
import java.util.regex.Matcher;
|
11
|
-
import java.util.regex.Pattern;
|
12
|
-
import org.embulk.config.ConfigException;
|
13
|
-
import org.embulk.spi.Column;
|
14
|
-
import static java.util.Locale.ENGLISH;
|
15
|
-
|
16
|
-
public class TimestampWithoutTimeZoneIncrementalHandler
|
17
|
-
extends AbstractIncrementalHandler
|
18
|
-
{
|
19
|
-
private static final String ISO_USEC_FORMAT = "%d-%02d-%02dT%02d:%02d:%02d.%06d";
|
20
|
-
private static final Pattern ISO_USEC_PATTERN = Pattern.compile("(\\d+)-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}).(\\d{6})");
|
21
|
-
|
22
|
-
private Timestamp dateTime;
|
23
|
-
|
24
|
-
public TimestampWithoutTimeZoneIncrementalHandler(ColumnGetter next)
|
25
|
-
{
|
26
|
-
super(next);
|
27
|
-
}
|
28
|
-
|
29
|
-
@Override
|
30
|
-
public void getAndSet(ResultSet from, int fromIndex,
|
31
|
-
Column toColumn) throws SQLException
|
32
|
-
{
|
33
|
-
// sniff the value
|
34
|
-
Timestamp timestamp = from.getTimestamp(fromIndex);
|
35
|
-
if (timestamp != null) {
|
36
|
-
this.dateTime = timestamp;
|
37
|
-
}
|
38
|
-
|
39
|
-
super.getAndSet(from, fromIndex, toColumn);
|
40
|
-
}
|
41
|
-
|
42
|
-
@Override
|
43
|
-
public JsonNode encodeToJson()
|
44
|
-
{
|
45
|
-
String text = String.format(ENGLISH,
|
46
|
-
ISO_USEC_FORMAT,
|
47
|
-
dateTime.getYear() + 1900,
|
48
|
-
dateTime.getMonth() + 1,
|
49
|
-
dateTime.getDate(),
|
50
|
-
dateTime.getHours(),
|
51
|
-
dateTime.getMinutes(),
|
52
|
-
dateTime.getSeconds(),
|
53
|
-
dateTime.getNanos() / 1000);
|
54
|
-
return jsonNodeFactory.textNode(text);
|
55
|
-
}
|
56
|
-
|
57
|
-
@Override
|
58
|
-
public void decodeFromJsonTo(PreparedStatement toStatement, int toIndex, JsonNode fromValue)
|
59
|
-
throws SQLException
|
60
|
-
{
|
61
|
-
Matcher matcher = ISO_USEC_PATTERN.matcher(fromValue.asText());
|
62
|
-
if (!matcher.matches()) {
|
63
|
-
throw new ConfigException("Invalid timestamp without time zone pattern: " + fromValue);
|
64
|
-
}
|
65
|
-
Timestamp sqlDateTime = new Timestamp(
|
66
|
-
Integer.parseInt(matcher.group(1)) - 1900, // year
|
67
|
-
Integer.parseInt(matcher.group(2)) - 1, // month
|
68
|
-
Integer.parseInt(matcher.group(3)), // day
|
69
|
-
Integer.parseInt(matcher.group(4)), // hour
|
70
|
-
Integer.parseInt(matcher.group(5)), // minute
|
71
|
-
Integer.parseInt(matcher.group(6)), // second
|
72
|
-
Integer.parseInt(matcher.group(7)) * 1000); // usec -> nsec
|
73
|
-
toStatement.setTimestamp(toIndex, sqlDateTime);
|
74
|
-
}
|
75
|
-
}
|