embulk-input-athena 0.1.2 → 0.1.7
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/Dockerfile +3 -5
- data/README.md +13 -8
- data/build.gradle +12 -12
- data/classpath/{AthenaJDBC41-1.1.0.jar → AthenaJDBC41.jar} +0 -0
- data/classpath/embulk-input-athena-0.1.7.jar +0 -0
- data/classpath/embulk-input-jdbc-0.12.2.jar +0 -0
- data/classpath/embulk-util-config-0.3.0.jar +0 -0
- data/classpath/embulk-util-json-0.1.1.jar +0 -0
- data/classpath/embulk-util-rubytime-0.3.2.jar +0 -0
- data/classpath/embulk-util-timestamp-0.2.1.jar +0 -0
- data/classpath/jackson-datatype-jdk8-2.6.7.jar +0 -0
- data/src/main/java/org/embulk/input/athena/AthenaInputConnection.java +2 -0
- data/src/main/java/org/embulk/input/athena/AthenaInputPlugin.java +101 -45
- data/src/main/resources/log4j.properties +4 -0
- metadata +30 -25
- data/classpath/embulk-input-athena-0.1.2.jar +0 -0
- data/classpath/embulk-input-jdbc-0.9.1.jar +0 -0
- data/src/main/java/org/embulk/input/athena/AthenaInputPlugin.java.tmp1 +0 -192
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0bfb1c9d3ca30be4dce909eb2506f57a82f1999
|
4
|
+
data.tar.gz: 6dc9ba9cc468b447d50cbe67402a75a0eb9348bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19f71b35de22b9a46838ac7e91b804383f41923a3ab0ef58fc8198aacf267e9288b68577c767cb2fa442c5cf0672f17541f123f7c4a7c9ef6482878d9e51f985
|
7
|
+
data.tar.gz: 11d62ec863d623ab40d5b10fb1e7d1ebcf8fbccc8dcb7a06f7296ee1d5a405dd6446594a8e9274b242adf2c1b290f5671c1d2a27678c1251bea9fda319ef65ab
|
data/Dockerfile
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
FROM openjdk:8-jdk
|
2
2
|
|
3
|
-
|
4
|
-
ENV EMBULK_VERSION 0.8.39
|
3
|
+
ENV EMBULK_VERSION 0.9.23
|
5
4
|
|
6
|
-
RUN curl --create-dirs -o
|
7
|
-
chmod +x
|
8
|
-
echo 'export PATH="$HOME/.embulk/bin:$PATH"' >> ~/.bashrc
|
5
|
+
RUN curl --create-dirs -o /usr/local/bin/embulk -L "https://dl.embulk.org/embulk-${EMBULK_VERSION}.jar" &&\
|
6
|
+
chmod +x /usr/local/bin/embulk
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Athena input plugin for Embulk
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/embulk-input-athena)
|
4
|
+
[](LICENSE)
|
5
|
+
|
3
6
|
Athena input plugin for Embulk loads records from Athena(AWS).
|
4
7
|
|
5
8
|
## Overview
|
@@ -11,15 +14,16 @@ Athena input plugin for Embulk loads records from Athena(AWS).
|
|
11
14
|
|
12
15
|
## Configuration
|
13
16
|
|
14
|
-
* **driver_path**: path to the jar file of the Athena JDBC driver. If not set, the bundled JDBC driver(AthenaJDBC41
|
15
|
-
* **database**:
|
16
|
-
* **athena_url**:
|
17
|
+
* **driver_path**: path to the jar file of the Athena JDBC driver. If not set, the bundled JDBC driver(AthenaJDBC41.jar) will be used. (string)
|
18
|
+
* **database**: database name (string, required)
|
19
|
+
* **athena_url**: Athena url (string, required)
|
17
20
|
* **s3_staging_dir**: The S3 location to which your query output is written, for example s3://query-results-bucket/folder/. (string, required)
|
18
|
-
* **access_key**:
|
19
|
-
* **secret_key**:
|
20
|
-
* **query**:
|
21
|
-
* **columns**:
|
22
|
-
* **options**:
|
21
|
+
* **access_key**: AWS access key (string, required)
|
22
|
+
* **secret_key**: AWS secret key (string, required)
|
23
|
+
* **query**: SQL to run (string, required)
|
24
|
+
* **columns**: columns (string, required)
|
25
|
+
* **options**: extra JDBC properties (string, default: {})
|
26
|
+
* **null_to_zero**: if true, convert long, double and boolean value from null to zero (boolean, default: false)
|
23
27
|
|
24
28
|
## Example
|
25
29
|
|
@@ -36,6 +40,7 @@ in:
|
|
36
40
|
columns:
|
37
41
|
- {name: uid, type: string}
|
38
42
|
- {name: created_at, type: timestamp}
|
43
|
+
null_to_zero: true
|
39
44
|
```
|
40
45
|
|
41
46
|
## Build
|
data/build.gradle
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
plugins {
|
2
2
|
id "com.jfrog.bintray" version "1.1"
|
3
|
-
id "com.github.jruby-gradle.base" version "
|
3
|
+
id "com.github.jruby-gradle.base" version "1.5.0"
|
4
4
|
id "java"
|
5
5
|
id "checkstyle"
|
6
6
|
// for task download
|
@@ -9,14 +9,12 @@ plugins {
|
|
9
9
|
import com.github.jrubygradle.JRubyExec
|
10
10
|
repositories {
|
11
11
|
mavenCentral()
|
12
|
-
jcenter()
|
13
|
-
maven { url "https://dl.bintray.com/embulk-input-jdbc/maven" }
|
14
12
|
}
|
15
13
|
configurations {
|
16
14
|
provided
|
17
15
|
}
|
18
16
|
|
19
|
-
version = "0.1.
|
17
|
+
version = "0.1.7"
|
20
18
|
|
21
19
|
sourceCompatibility = 1.8
|
22
20
|
targetCompatibility = 1.8
|
@@ -25,15 +23,15 @@ dependencies {
|
|
25
23
|
compile "org.embulk:embulk-core:0.8.39"
|
26
24
|
provided "org.embulk:embulk-core:0.8.39"
|
27
25
|
// TODO: maven...
|
28
|
-
compile files ('build/AthenaJDBC41
|
26
|
+
compile files ('build/AthenaJDBC41.jar')
|
29
27
|
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.301'
|
30
28
|
// compile group: 'com.amazonaws', name: 'aws-java-sdk-athena', version: '1.11.301'
|
31
|
-
compile 'org.embulk
|
29
|
+
compile 'org.embulk:embulk-input-jdbc:0.12.2'
|
32
30
|
testCompile "junit:junit:4.+"
|
33
31
|
}
|
34
32
|
|
35
33
|
task downloadFile(type: Download) {
|
36
|
-
src 'https://s3.amazonaws.com/athena-downloads/drivers/
|
34
|
+
src 'https://s3.amazonaws.com/athena-downloads/drivers/JDBC/SimbaAthenaJDBC-2.0.23.1000/AthenaJDBC41.jar'
|
37
35
|
dest buildDir
|
38
36
|
onlyIfModified true
|
39
37
|
}
|
@@ -41,7 +39,7 @@ task downloadFile(type: Download) {
|
|
41
39
|
task classpath(type: Copy, dependsOn: ["downloadFile", "jar"]) {
|
42
40
|
doFirst { file("classpath").deleteDir() }
|
43
41
|
from (configurations.runtime - configurations.provided + files(jar.archivePath))
|
44
|
-
from ("build/AthenaJDBC41
|
42
|
+
from ("build/AthenaJDBC41.jar")
|
45
43
|
into "classpath"
|
46
44
|
}
|
47
45
|
clean { delete "classpath" }
|
@@ -64,14 +62,16 @@ task checkstyle(type: Checkstyle) {
|
|
64
62
|
}
|
65
63
|
|
66
64
|
task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
|
67
|
-
jrubyArgs "-
|
68
|
-
script "
|
65
|
+
jrubyArgs "-S"
|
66
|
+
script "gem"
|
67
|
+
scriptArgs "build", "${project.name}.gemspec"
|
69
68
|
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
|
70
69
|
}
|
71
70
|
|
72
71
|
task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
|
73
|
-
jrubyArgs "-
|
74
|
-
script "
|
72
|
+
jrubyArgs "-S"
|
73
|
+
script "gem"
|
74
|
+
scriptArgs "push", "pkg/${project.name}-${project.version}.gem"
|
75
75
|
}
|
76
76
|
|
77
77
|
task "package"(dependsOn: ["gemspec", "classpath"]) {
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,5 +1,7 @@
|
|
1
1
|
package org.embulk.input.athena;
|
2
2
|
|
3
|
+
import com.google.common.base.Optional;
|
4
|
+
|
3
5
|
import java.io.File;
|
4
6
|
import java.io.FileFilter;
|
5
7
|
import java.net.MalformedURLException;
|
@@ -10,14 +12,11 @@ import java.nio.file.Paths;
|
|
10
12
|
import java.sql.Connection;
|
11
13
|
import java.sql.DriverManager;
|
12
14
|
import java.sql.ResultSet;
|
13
|
-
import java.sql.ResultSetMetaData;
|
14
15
|
import java.sql.SQLException;
|
15
16
|
import java.sql.Statement;
|
16
17
|
import java.util.List;
|
17
18
|
import java.util.Properties;
|
18
19
|
|
19
|
-
import com.google.common.base.Optional;
|
20
|
-
|
21
20
|
import org.embulk.config.Config;
|
22
21
|
import org.embulk.config.ConfigDefault;
|
23
22
|
import org.embulk.config.ConfigDiff;
|
@@ -41,15 +40,16 @@ import org.embulk.spi.SchemaConfig;
|
|
41
40
|
import org.embulk.spi.time.Timestamp;
|
42
41
|
import org.slf4j.Logger;
|
43
42
|
|
44
|
-
public class AthenaInputPlugin implements InputPlugin
|
45
|
-
|
43
|
+
public class AthenaInputPlugin implements InputPlugin
|
44
|
+
{
|
46
45
|
protected final Logger logger = Exec.getLogger(getClass());
|
47
46
|
|
48
|
-
public interface PluginTask extends Task
|
47
|
+
public interface PluginTask extends Task
|
48
|
+
{
|
49
49
|
@Config("driver_path")
|
50
50
|
@ConfigDefault("null")
|
51
|
-
public Optional
|
52
|
-
|
51
|
+
public Optional<String> getDriverPath();
|
52
|
+
|
53
53
|
// database (required string)
|
54
54
|
@Config("database")
|
55
55
|
public String getDatabase();
|
@@ -82,12 +82,17 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
82
82
|
@ConfigDefault("{}")
|
83
83
|
public ToStringMap getOptions();
|
84
84
|
|
85
|
+
@Config("null_to_zero")
|
86
|
+
@ConfigDefault("false")
|
87
|
+
public boolean getNullToZero();
|
88
|
+
|
85
89
|
@ConfigInject
|
86
90
|
BufferAllocator getBufferAllocator();
|
87
91
|
}
|
88
92
|
|
89
93
|
@Override
|
90
|
-
public ConfigDiff transaction(ConfigSource config, InputPlugin.Control control)
|
94
|
+
public ConfigDiff transaction(ConfigSource config, InputPlugin.Control control)
|
95
|
+
{
|
91
96
|
PluginTask task = config.loadConfig(PluginTask.class);
|
92
97
|
|
93
98
|
Schema schema = task.getColumns().toSchema();
|
@@ -97,17 +102,20 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
97
102
|
}
|
98
103
|
|
99
104
|
@Override
|
100
|
-
public ConfigDiff resume(TaskSource taskSource, Schema schema, int taskCount, InputPlugin.Control control)
|
105
|
+
public ConfigDiff resume(TaskSource taskSource, Schema schema, int taskCount, InputPlugin.Control control)
|
106
|
+
{
|
101
107
|
control.run(taskSource, schema, taskCount);
|
102
108
|
return Exec.newConfigDiff();
|
103
109
|
}
|
104
110
|
|
105
111
|
@Override
|
106
|
-
public void cleanup(TaskSource taskSource, Schema schema, int taskCount, List<TaskReport> successTaskReports)
|
112
|
+
public void cleanup(TaskSource taskSource, Schema schema, int taskCount, List<TaskReport> successTaskReports)
|
113
|
+
{
|
107
114
|
}
|
108
115
|
|
109
116
|
@Override
|
110
|
-
public TaskReport run(TaskSource taskSource, Schema schema, int taskIndex, PageOutput output)
|
117
|
+
public TaskReport run(TaskSource taskSource, Schema schema, int taskIndex, PageOutput output)
|
118
|
+
{
|
111
119
|
PluginTask task = taskSource.loadTask(PluginTask.class);
|
112
120
|
BufferAllocator allocator = task.getBufferAllocator();
|
113
121
|
PageBuilder pageBuilder = new PageBuilder(allocator, schema, output);
|
@@ -120,58 +128,93 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
120
128
|
connection = getAthenaConnection(task);
|
121
129
|
statement = connection.createStatement();
|
122
130
|
ResultSet resultSet = statement.executeQuery(task.getQuery());
|
131
|
+
boolean nullToZero = task.getNullToZero();
|
123
132
|
|
124
|
-
ResultSetMetaData m = resultSet.getMetaData();
|
125
133
|
while (resultSet.next()) {
|
126
|
-
schema.visitColumns(new ColumnVisitor()
|
134
|
+
schema.visitColumns(new ColumnVisitor()
|
135
|
+
{
|
127
136
|
@Override
|
128
|
-
public void timestampColumn(Column column)
|
137
|
+
public void timestampColumn(Column column)
|
138
|
+
{
|
129
139
|
try {
|
130
140
|
java.sql.Timestamp t = resultSet.getTimestamp(column.getName());
|
131
141
|
pageBuilder.setTimestamp(column, Timestamp.ofEpochMilli(t.getTime()));
|
132
|
-
}
|
142
|
+
}
|
143
|
+
catch (SQLException e) {
|
133
144
|
e.printStackTrace();
|
145
|
+
throw new RuntimeException(e);
|
134
146
|
}
|
135
147
|
}
|
136
148
|
|
137
149
|
@Override
|
138
|
-
public void stringColumn(Column column)
|
150
|
+
public void stringColumn(Column column)
|
151
|
+
{
|
139
152
|
try {
|
140
153
|
pageBuilder.setString(column, resultSet.getString(column.getName()));
|
141
|
-
}
|
154
|
+
}
|
155
|
+
catch (SQLException e) {
|
142
156
|
e.printStackTrace();
|
157
|
+
throw new RuntimeException(e);
|
143
158
|
}
|
144
159
|
}
|
145
160
|
|
146
161
|
@Override
|
147
|
-
public void longColumn(Column column)
|
162
|
+
public void longColumn(Column column)
|
163
|
+
{
|
148
164
|
try {
|
149
|
-
|
150
|
-
|
165
|
+
long ret = resultSet.getLong(column.getName());
|
166
|
+
if (resultSet.wasNull() && !nullToZero){
|
167
|
+
pageBuilder.setNull(column);
|
168
|
+
}
|
169
|
+
else {
|
170
|
+
pageBuilder.setLong(column, ret);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
catch (SQLException e) {
|
151
174
|
e.printStackTrace();
|
175
|
+
throw new RuntimeException(e);
|
152
176
|
}
|
153
177
|
}
|
154
178
|
|
155
179
|
@Override
|
156
|
-
public void doubleColumn(Column column)
|
180
|
+
public void doubleColumn(Column column)
|
181
|
+
{
|
157
182
|
try {
|
158
|
-
|
159
|
-
|
183
|
+
double ret = resultSet.getDouble(column.getName());
|
184
|
+
if (resultSet.wasNull() && !nullToZero){
|
185
|
+
pageBuilder.setNull(column);
|
186
|
+
}
|
187
|
+
else {
|
188
|
+
pageBuilder.setDouble(column, ret);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
catch (SQLException e) {
|
160
192
|
e.printStackTrace();
|
193
|
+
throw new RuntimeException(e);
|
161
194
|
}
|
162
195
|
}
|
163
196
|
|
164
197
|
@Override
|
165
|
-
public void booleanColumn(Column column)
|
198
|
+
public void booleanColumn(Column column)
|
199
|
+
{
|
166
200
|
try {
|
167
|
-
|
168
|
-
|
201
|
+
boolean ret = resultSet.getBoolean(column.getName());
|
202
|
+
if (resultSet.wasNull() && !nullToZero){
|
203
|
+
pageBuilder.setNull(column);
|
204
|
+
}
|
205
|
+
else {
|
206
|
+
pageBuilder.setBoolean(column, ret);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
catch (SQLException e) {
|
169
210
|
e.printStackTrace();
|
211
|
+
throw new RuntimeException(e);
|
170
212
|
}
|
171
213
|
}
|
172
214
|
|
173
215
|
@Override
|
174
|
-
public void jsonColumn(Column column)
|
216
|
+
public void jsonColumn(Column column)
|
217
|
+
{
|
175
218
|
// TODO:
|
176
219
|
}
|
177
220
|
});
|
@@ -183,19 +226,24 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
183
226
|
pageBuilder.close();
|
184
227
|
resultSet.close();
|
185
228
|
connection.close();
|
186
|
-
}
|
229
|
+
}
|
230
|
+
catch (Exception e) {
|
187
231
|
e.printStackTrace();
|
188
|
-
|
232
|
+
throw new RuntimeException(e);
|
233
|
+
}
|
234
|
+
finally {
|
189
235
|
try {
|
190
|
-
if (statement != null)
|
236
|
+
if (statement != null) {
|
191
237
|
statement.close();
|
192
|
-
|
193
|
-
|
238
|
+
}
|
194
239
|
}
|
240
|
+
catch (Exception ex) { }
|
195
241
|
try {
|
196
|
-
if (connection != null)
|
242
|
+
if (connection != null) {
|
197
243
|
connection.close();
|
198
|
-
|
244
|
+
}
|
245
|
+
}
|
246
|
+
catch (Exception ex) {
|
199
247
|
ex.printStackTrace();
|
200
248
|
}
|
201
249
|
}
|
@@ -204,16 +252,19 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
204
252
|
}
|
205
253
|
|
206
254
|
@Override
|
207
|
-
public ConfigDiff guess(ConfigSource config)
|
255
|
+
public ConfigDiff guess(ConfigSource config)
|
256
|
+
{
|
208
257
|
return Exec.newConfigDiff();
|
209
258
|
}
|
210
259
|
|
211
|
-
protected Connection getAthenaConnection(PluginTask task) throws ClassNotFoundException, SQLException
|
212
|
-
|
260
|
+
protected Connection getAthenaConnection(PluginTask task) throws ClassNotFoundException, SQLException
|
261
|
+
{
|
262
|
+
loadDriver("com.simba.athena.jdbc.Driver", task.getDriverPath());
|
213
263
|
Properties properties = new Properties();
|
214
264
|
properties.put("s3_staging_dir", task.getS3StagingDir());
|
215
265
|
properties.put("user", task.getAccessKey());
|
216
266
|
properties.put("password", task.getSecretKey());
|
267
|
+
properties.put("schema", task.getDatabase());
|
217
268
|
properties.putAll(task.getOptions());
|
218
269
|
|
219
270
|
return DriverManager.getConnection(task.getAthenaUrl(), properties);
|
@@ -227,23 +278,26 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
227
278
|
{
|
228
279
|
if (driverPath.isPresent()) {
|
229
280
|
addDriverJarToClasspath(driverPath.get());
|
230
|
-
}
|
281
|
+
}
|
282
|
+
else {
|
231
283
|
try {
|
232
284
|
// Gradle test task will add JDBC driver to classpath
|
233
285
|
Class.forName(className);
|
234
|
-
|
235
|
-
|
286
|
+
}
|
287
|
+
catch (ClassNotFoundException ex) {
|
236
288
|
File root = findPluginRoot();
|
237
289
|
File driverLib = new File(root, "default_jdbc_driver");
|
238
290
|
File[] files = driverLib.listFiles(new FileFilter() {
|
239
291
|
@Override
|
240
|
-
public boolean accept(File file)
|
292
|
+
public boolean accept(File file)
|
293
|
+
{
|
241
294
|
return file.isFile() && file.getName().endsWith(".jar");
|
242
295
|
}
|
243
296
|
});
|
244
297
|
if (files == null || files.length == 0) {
|
245
298
|
throw new RuntimeException("Cannot find JDBC driver in '" + root.getAbsolutePath() + "'.");
|
246
|
-
}
|
299
|
+
}
|
300
|
+
else {
|
247
301
|
for (File file : files) {
|
248
302
|
logger.info("JDBC Driver = " + file.getAbsolutePath());
|
249
303
|
addDriverJarToClasspath(file.getAbsolutePath());
|
@@ -255,7 +309,8 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
255
309
|
// Load JDBC Driver
|
256
310
|
try {
|
257
311
|
Class.forName(className);
|
258
|
-
}
|
312
|
+
}
|
313
|
+
catch (ClassNotFoundException ex) {
|
259
314
|
throw new RuntimeException(ex);
|
260
315
|
}
|
261
316
|
}
|
@@ -289,7 +344,8 @@ public class AthenaInputPlugin implements InputPlugin {
|
|
289
344
|
return folder;
|
290
345
|
}
|
291
346
|
}
|
292
|
-
}
|
347
|
+
}
|
348
|
+
catch (MalformedURLException | URISyntaxException e) {
|
293
349
|
throw new RuntimeException(e);
|
294
350
|
}
|
295
351
|
}
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-athena
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shinji19
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - ~>
|
16
|
+
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: '1.0'
|
19
19
|
name: bundler
|
@@ -21,13 +21,13 @@ dependencies:
|
|
21
21
|
type: :development
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '10.0'
|
33
33
|
name: rake
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
type: :development
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
description: Loads records from Athena.
|
@@ -45,24 +45,12 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- Dockerfile
|
50
50
|
- LICENSE
|
51
51
|
- README.md
|
52
52
|
- build.gradle
|
53
|
-
-
|
54
|
-
- config/checkstyle/default.xml
|
55
|
-
- docker-compose.yml
|
56
|
-
- gradle/wrapper/gradle-wrapper.jar
|
57
|
-
- gradle/wrapper/gradle-wrapper.properties
|
58
|
-
- gradlew
|
59
|
-
- gradlew.bat
|
60
|
-
- lib/embulk/input/athena.rb
|
61
|
-
- src/main/java/org/embulk/input/athena/AthenaInputConnection.java
|
62
|
-
- src/main/java/org/embulk/input/athena/AthenaInputPlugin.java
|
63
|
-
- src/main/java/org/embulk/input/athena/AthenaInputPlugin.java.tmp1
|
64
|
-
- src/test/java/org/embulk/input/athena/TestAthenaInputPlugin.java
|
65
|
-
- classpath/AthenaJDBC41-1.1.0.jar
|
53
|
+
- classpath/AthenaJDBC41.jar
|
66
54
|
- classpath/aws-java-sdk-1.11.301.jar
|
67
55
|
- classpath/aws-java-sdk-acm-1.11.301.jar
|
68
56
|
- classpath/aws-java-sdk-alexaforbusiness-1.11.301.jar
|
@@ -192,13 +180,18 @@ files:
|
|
192
180
|
- classpath/aws-java-sdk-xray-1.11.301.jar
|
193
181
|
- classpath/commons-codec-1.10.jar
|
194
182
|
- classpath/commons-logging-1.2.jar
|
195
|
-
- classpath/embulk-input-athena-0.1.
|
196
|
-
- classpath/embulk-input-jdbc-0.
|
183
|
+
- classpath/embulk-input-athena-0.1.7.jar
|
184
|
+
- classpath/embulk-input-jdbc-0.12.2.jar
|
185
|
+
- classpath/embulk-util-config-0.3.0.jar
|
186
|
+
- classpath/embulk-util-json-0.1.1.jar
|
187
|
+
- classpath/embulk-util-rubytime-0.3.2.jar
|
188
|
+
- classpath/embulk-util-timestamp-0.2.1.jar
|
197
189
|
- classpath/httpclient-4.5.5.jar
|
198
190
|
- classpath/httpcore-4.4.9.jar
|
199
191
|
- classpath/ion-java-1.0.2.jar
|
200
192
|
- classpath/jackson-databind-2.6.7.1.jar
|
201
193
|
- classpath/jackson-dataformat-cbor-2.6.7.jar
|
194
|
+
- classpath/jackson-datatype-jdk8-2.6.7.jar
|
202
195
|
- classpath/jmespath-java-1.11.301.jar
|
203
196
|
- classpath/netty-buffer-4.1.17.Final.jar
|
204
197
|
- classpath/netty-codec-4.1.17.Final.jar
|
@@ -207,6 +200,18 @@ files:
|
|
207
200
|
- classpath/netty-handler-4.1.17.Final.jar
|
208
201
|
- classpath/netty-resolver-4.1.17.Final.jar
|
209
202
|
- classpath/netty-transport-4.1.17.Final.jar
|
203
|
+
- config/checkstyle/checkstyle.xml
|
204
|
+
- config/checkstyle/default.xml
|
205
|
+
- docker-compose.yml
|
206
|
+
- gradle/wrapper/gradle-wrapper.jar
|
207
|
+
- gradle/wrapper/gradle-wrapper.properties
|
208
|
+
- gradlew
|
209
|
+
- gradlew.bat
|
210
|
+
- lib/embulk/input/athena.rb
|
211
|
+
- src/main/java/org/embulk/input/athena/AthenaInputConnection.java
|
212
|
+
- src/main/java/org/embulk/input/athena/AthenaInputPlugin.java
|
213
|
+
- src/main/resources/log4j.properties
|
214
|
+
- src/test/java/org/embulk/input/athena/TestAthenaInputPlugin.java
|
210
215
|
homepage: https://github.com/shinji19/embulk-input-athena
|
211
216
|
licenses:
|
212
217
|
- MIT
|
@@ -217,17 +222,17 @@ require_paths:
|
|
217
222
|
- lib
|
218
223
|
required_ruby_version: !ruby/object:Gem::Requirement
|
219
224
|
requirements:
|
220
|
-
- -
|
225
|
+
- - ">="
|
221
226
|
- !ruby/object:Gem::Version
|
222
227
|
version: '0'
|
223
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
229
|
requirements:
|
225
|
-
- -
|
230
|
+
- - ">="
|
226
231
|
- !ruby/object:Gem::Version
|
227
232
|
version: '0'
|
228
233
|
requirements: []
|
229
234
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.
|
235
|
+
rubygems_version: 2.6.8
|
231
236
|
signing_key:
|
232
237
|
specification_version: 4
|
233
238
|
summary: Athena input plugin for Embulk
|
Binary file
|
Binary file
|
@@ -1,192 +0,0 @@
|
|
1
|
-
package org.embulk.input.athena;
|
2
|
-
|
3
|
-
import java.sql.Connection;
|
4
|
-
import java.sql.DriverManager;
|
5
|
-
import java.sql.ResultSet;
|
6
|
-
import java.sql.SQLException;
|
7
|
-
import java.sql.Statement;
|
8
|
-
import java.util.List;
|
9
|
-
import java.util.Properties;
|
10
|
-
|
11
|
-
import com.google.common.base.Optional;
|
12
|
-
|
13
|
-
import org.embulk.config.Config;
|
14
|
-
import org.embulk.config.ConfigDefault;
|
15
|
-
import org.embulk.config.ConfigDiff;
|
16
|
-
import org.embulk.config.ConfigSource;
|
17
|
-
import org.embulk.config.Task;
|
18
|
-
import org.embulk.config.TaskReport;
|
19
|
-
import org.embulk.config.TaskSource;
|
20
|
-
import org.embulk.input.jdbc.AbstractJdbcInputPlugin;
|
21
|
-
import org.embulk.input.jdbc.JdbcInputConnection;
|
22
|
-
import org.embulk.spi.Exec;
|
23
|
-
import org.embulk.spi.InputPlugin;
|
24
|
-
import org.embulk.spi.PageOutput;
|
25
|
-
import org.embulk.spi.Schema;
|
26
|
-
import org.embulk.spi.SchemaConfig;
|
27
|
-
|
28
|
-
public class AthenaInputPlugin
|
29
|
-
extends AbstractJdbcInputPlugin
|
30
|
-
{
|
31
|
-
public interface AthenaPluginTask
|
32
|
-
extends AbstractJdbcInputPlugin.PluginTask
|
33
|
-
{
|
34
|
-
@Config("driver_path")
|
35
|
-
@ConfigDefault("null")
|
36
|
-
public Optional<String> getDriverPath();
|
37
|
-
|
38
|
-
// athena_url (required string)
|
39
|
-
@Config("athena_url")
|
40
|
-
public String getAthenaUrl();
|
41
|
-
|
42
|
-
// s3_staging_dir (required string)
|
43
|
-
@Config("s3_staging_dir")
|
44
|
-
public String getS3StagingDir();
|
45
|
-
|
46
|
-
// access_key (required string)
|
47
|
-
@Config("access_key")
|
48
|
-
public String getAccessKey();
|
49
|
-
|
50
|
-
// secret_key (required string)
|
51
|
-
@Config("secret_key")
|
52
|
-
public String getSecretKey();
|
53
|
-
|
54
|
-
// configuration option 2 (optional string, null is not allowed)
|
55
|
-
// @Config("option2")
|
56
|
-
// @ConfigDefault("\"myvalue\"")
|
57
|
-
// public String getOption2();
|
58
|
-
|
59
|
-
// configuration option 3 (optional string, null is allowed)
|
60
|
-
// @Config("option3")
|
61
|
-
// @ConfigDefault("null")
|
62
|
-
// public Optional<String> getOption3();
|
63
|
-
|
64
|
-
// if you get schema from config
|
65
|
-
// @Config("columns")
|
66
|
-
// public SchemaConfig getColumns();
|
67
|
-
}
|
68
|
-
|
69
|
-
@Override
|
70
|
-
protected Class<? extends PluginTask> getTaskClass() {
|
71
|
-
return AthenaPluginTask.class;
|
72
|
-
}
|
73
|
-
|
74
|
-
@Override
|
75
|
-
protected AthenaInputConnection newConnection(PluginTask pluginTask) throws SQLException {
|
76
|
-
AthenaPluginTask task = (AthenaPluginTask) pluginTask;
|
77
|
-
loadDriver("com.amazonaws.athena.jdbc.AthenaDriver", task.getDriverPath());
|
78
|
-
//Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");
|
79
|
-
Properties properties = new Properties();
|
80
|
-
properties.put("s3_staging_dir", task.getS3StagingDir());
|
81
|
-
properties.put("user", task.getAccessKey());
|
82
|
-
properties.put("password", task.getSecretKey());
|
83
|
-
properties.putAll(task.getOptions());
|
84
|
-
|
85
|
-
Connection connection = DriverManager.getConnection(task.getAthenaUrl(), properties);
|
86
|
-
try {
|
87
|
-
AthenaInputConnection c = new AthenaInputConnection(connection);
|
88
|
-
connection = null;
|
89
|
-
return c;
|
90
|
-
} finally {
|
91
|
-
if (connection != null) {
|
92
|
-
connection.close();
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
/*
|
98
|
-
@Override
|
99
|
-
public ConfigDiff transaction(ConfigSource config,
|
100
|
-
InputPlugin.Control control)
|
101
|
-
{
|
102
|
-
PluginTask task = config.loadConfig(PluginTask.class);
|
103
|
-
|
104
|
-
// Schema schema = task.getColumns().toSchema();
|
105
|
-
Schema schema = Schema.builder().build();
|
106
|
-
int taskCount = 1; // number of run() method calls
|
107
|
-
|
108
|
-
return resume(task.dump(), schema, taskCount, control);
|
109
|
-
}
|
110
|
-
|
111
|
-
@Override
|
112
|
-
public ConfigDiff resume(TaskSource taskSource,
|
113
|
-
Schema schema, int taskCount,
|
114
|
-
InputPlugin.Control control)
|
115
|
-
{
|
116
|
-
control.run(taskSource, schema, taskCount);
|
117
|
-
return Exec.newConfigDiff();
|
118
|
-
}
|
119
|
-
|
120
|
-
@Override
|
121
|
-
public void cleanup(TaskSource taskSource,
|
122
|
-
Schema schema, int taskCount,
|
123
|
-
List<TaskReport> successTaskReports)
|
124
|
-
{
|
125
|
-
}
|
126
|
-
|
127
|
-
@Override
|
128
|
-
public TaskReport run(TaskSource taskSource,
|
129
|
-
Schema schema, int taskIndex,
|
130
|
-
PageOutput output)
|
131
|
-
{
|
132
|
-
PluginTask task = taskSource.loadTask(PluginTask.class);
|
133
|
-
|
134
|
-
// Write your code here :)
|
135
|
-
|
136
|
-
Connection connection = null;
|
137
|
-
Statement statement = null;
|
138
|
-
try {
|
139
|
-
connection = getAthenaConnection(task);
|
140
|
-
statement = connection.createStatement();
|
141
|
-
ResultSet resultSet = statement.executeQuery("select * from default.sample");
|
142
|
-
|
143
|
-
while(resultSet.next()){
|
144
|
-
String statusCode = resultSet.getString("created_at");
|
145
|
-
System.out.println("st code" + statusCode);
|
146
|
-
}
|
147
|
-
resultSet.close();
|
148
|
-
connection.close();
|
149
|
-
} catch (Exception e){
|
150
|
-
e.printStackTrace();
|
151
|
-
} finally {
|
152
|
-
try {
|
153
|
-
if (statement != null)
|
154
|
-
statement.close();
|
155
|
-
} catch (Exception ex) {
|
156
|
-
|
157
|
-
}
|
158
|
-
try {
|
159
|
-
if (connection != null)
|
160
|
-
connection.close();
|
161
|
-
} catch (Exception ex) {
|
162
|
-
ex.printStackTrace();
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
|
-
return Exec.newTaskReport();
|
167
|
-
}
|
168
|
-
|
169
|
-
@Override
|
170
|
-
public ConfigDiff guess(ConfigSource config)
|
171
|
-
{
|
172
|
-
return Exec.newConfigDiff();
|
173
|
-
}
|
174
|
-
*/
|
175
|
-
/*
|
176
|
-
protected Connection getAthenaConnection(PluginTask task) throws ClassNotFoundException, SQLException{
|
177
|
-
Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");
|
178
|
-
Properties properties = new Properties();
|
179
|
-
properties.put("s3_staging_dir", task.getS3StagingDir());
|
180
|
-
properties.put("user", task.getAccessKey());
|
181
|
-
properties.put("password", task.getSecretKey());
|
182
|
-
if (task.getLogPath() != null){
|
183
|
-
properties.put("log_path", task.getLogPath());
|
184
|
-
}
|
185
|
-
if (task.getLogLevel() != null){
|
186
|
-
properties.put("log_level", task.getLogLevel());
|
187
|
-
}
|
188
|
-
|
189
|
-
return DriverManager.getConnection(task.getAthenaUrl(), properties);
|
190
|
-
}
|
191
|
-
*/
|
192
|
-
}
|