embulk-input-athena 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/Dockerfile +8 -0
  4. data/LICENSE +21 -0
  5. data/README.md +46 -0
  6. data/build.gradle +101 -0
  7. data/config/checkstyle/checkstyle.xml +128 -0
  8. data/config/checkstyle/default.xml +108 -0
  9. data/docker-compose.yml +10 -0
  10. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  11. data/gradle/wrapper/gradle-wrapper.properties +5 -0
  12. data/gradlew +172 -0
  13. data/gradlew.bat +84 -0
  14. data/lib/embulk/input/athena.rb +3 -0
  15. data/src/main/java/org/embulk/input/athena/AthenaInputConnection.java +49 -0
  16. data/src/main/java/org/embulk/input/athena/AthenaInputPlugin.java +202 -0
  17. data/src/main/java/org/embulk/input/athena/AthenaInputPlugin.java.tmp1 +192 -0
  18. data/src/main/java/org/embulk/input/jdbc/AbstractJdbcInputPlugin.java +674 -0
  19. data/src/main/java/org/embulk/input/jdbc/JdbcColumn.java +58 -0
  20. data/src/main/java/org/embulk/input/jdbc/JdbcColumnOption.java +31 -0
  21. data/src/main/java/org/embulk/input/jdbc/JdbcInputConnection.java +397 -0
  22. data/src/main/java/org/embulk/input/jdbc/JdbcLiteral.java +38 -0
  23. data/src/main/java/org/embulk/input/jdbc/JdbcSchema.java +55 -0
  24. data/src/main/java/org/embulk/input/jdbc/Ssl.java +37 -0
  25. data/src/main/java/org/embulk/input/jdbc/ToString.java +54 -0
  26. data/src/main/java/org/embulk/input/jdbc/ToStringMap.java +35 -0
  27. data/src/main/java/org/embulk/input/jdbc/getter/AbstractColumnGetter.java +105 -0
  28. data/src/main/java/org/embulk/input/jdbc/getter/AbstractIncrementalHandler.java +45 -0
  29. data/src/main/java/org/embulk/input/jdbc/getter/AbstractTimestampColumnGetter.java +38 -0
  30. data/src/main/java/org/embulk/input/jdbc/getter/BigDecimalColumnGetter.java +59 -0
  31. data/src/main/java/org/embulk/input/jdbc/getter/BooleanColumnGetter.java +56 -0
  32. data/src/main/java/org/embulk/input/jdbc/getter/ColumnGetter.java +21 -0
  33. data/src/main/java/org/embulk/input/jdbc/getter/ColumnGetterFactory.java +207 -0
  34. data/src/main/java/org/embulk/input/jdbc/getter/DateColumnGetter.java +37 -0
  35. data/src/main/java/org/embulk/input/jdbc/getter/DoubleColumnGetter.java +66 -0
  36. data/src/main/java/org/embulk/input/jdbc/getter/FloatColumnGetter.java +66 -0
  37. data/src/main/java/org/embulk/input/jdbc/getter/JsonColumnGetter.java +57 -0
  38. data/src/main/java/org/embulk/input/jdbc/getter/LongColumnGetter.java +70 -0
  39. data/src/main/java/org/embulk/input/jdbc/getter/StringColumnGetter.java +96 -0
  40. data/src/main/java/org/embulk/input/jdbc/getter/TimeColumnGetter.java +37 -0
  41. data/src/main/java/org/embulk/input/jdbc/getter/TimestampColumnGetter.java +36 -0
  42. data/src/main/java/org/embulk/input/jdbc/getter/TimestampWithTimeZoneIncrementalHandler.java +83 -0
  43. data/src/main/java/org/embulk/input/jdbc/getter/TimestampWithoutTimeZoneIncrementalHandler.java +75 -0
  44. data/src/test/java/org/embulk/input/athena/TestAthenaInputPlugin.java +5 -0
  45. metadata +258 -0
Binary file
@@ -0,0 +1,5 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ zipStoreBase=GRADLE_USER_HOME
4
+ zipStorePath=wrapper/dists
5
+ distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
data/gradlew ADDED
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env sh
2
+
3
+ ##############################################################################
4
+ ##
5
+ ## Gradle start up script for UN*X
6
+ ##
7
+ ##############################################################################
8
+
9
+ # Attempt to set APP_HOME
10
+ # Resolve links: $0 may be a link
11
+ PRG="$0"
12
+ # Need this for relative symlinks.
13
+ while [ -h "$PRG" ] ; do
14
+ ls=`ls -ld "$PRG"`
15
+ link=`expr "$ls" : '.*-> \(.*\)$'`
16
+ if expr "$link" : '/.*' > /dev/null; then
17
+ PRG="$link"
18
+ else
19
+ PRG=`dirname "$PRG"`"/$link"
20
+ fi
21
+ done
22
+ SAVED="`pwd`"
23
+ cd "`dirname \"$PRG\"`/" >/dev/null
24
+ APP_HOME="`pwd -P`"
25
+ cd "$SAVED" >/dev/null
26
+
27
+ APP_NAME="Gradle"
28
+ APP_BASE_NAME=`basename "$0"`
29
+
30
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
+ DEFAULT_JVM_OPTS=""
32
+
33
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
34
+ MAX_FD="maximum"
35
+
36
+ warn () {
37
+ echo "$*"
38
+ }
39
+
40
+ die () {
41
+ echo
42
+ echo "$*"
43
+ echo
44
+ exit 1
45
+ }
46
+
47
+ # OS specific support (must be 'true' or 'false').
48
+ cygwin=false
49
+ msys=false
50
+ darwin=false
51
+ nonstop=false
52
+ case "`uname`" in
53
+ CYGWIN* )
54
+ cygwin=true
55
+ ;;
56
+ Darwin* )
57
+ darwin=true
58
+ ;;
59
+ MINGW* )
60
+ msys=true
61
+ ;;
62
+ NONSTOP* )
63
+ nonstop=true
64
+ ;;
65
+ esac
66
+
67
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68
+
69
+ # Determine the Java command to use to start the JVM.
70
+ if [ -n "$JAVA_HOME" ] ; then
71
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72
+ # IBM's JDK on AIX uses strange locations for the executables
73
+ JAVACMD="$JAVA_HOME/jre/sh/java"
74
+ else
75
+ JAVACMD="$JAVA_HOME/bin/java"
76
+ fi
77
+ if [ ! -x "$JAVACMD" ] ; then
78
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79
+
80
+ Please set the JAVA_HOME variable in your environment to match the
81
+ location of your Java installation."
82
+ fi
83
+ else
84
+ JAVACMD="java"
85
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86
+
87
+ Please set the JAVA_HOME variable in your environment to match the
88
+ location of your Java installation."
89
+ fi
90
+
91
+ # Increase the maximum file descriptors if we can.
92
+ if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93
+ MAX_FD_LIMIT=`ulimit -H -n`
94
+ if [ $? -eq 0 ] ; then
95
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96
+ MAX_FD="$MAX_FD_LIMIT"
97
+ fi
98
+ ulimit -n $MAX_FD
99
+ if [ $? -ne 0 ] ; then
100
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
101
+ fi
102
+ else
103
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104
+ fi
105
+ fi
106
+
107
+ # For Darwin, add options to specify how the application appears in the dock
108
+ if $darwin; then
109
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110
+ fi
111
+
112
+ # For Cygwin, switch paths to Windows format before running java
113
+ if $cygwin ; then
114
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116
+ JAVACMD=`cygpath --unix "$JAVACMD"`
117
+
118
+ # We build the pattern for arguments to be converted via cygpath
119
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
+ SEP=""
121
+ for dir in $ROOTDIRSRAW ; do
122
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
123
+ SEP="|"
124
+ done
125
+ OURCYGPATTERN="(^($ROOTDIRS))"
126
+ # Add a user-defined pattern to the cygpath arguments
127
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
+ fi
130
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
+ i=0
132
+ for arg in "$@" ; do
133
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135
+
136
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
+ else
139
+ eval `echo args$i`="\"$arg\""
140
+ fi
141
+ i=$((i+1))
142
+ done
143
+ case $i in
144
+ (0) set -- ;;
145
+ (1) set -- "$args0" ;;
146
+ (2) set -- "$args0" "$args1" ;;
147
+ (3) set -- "$args0" "$args1" "$args2" ;;
148
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
+ esac
155
+ fi
156
+
157
+ # Escape application args
158
+ save () {
159
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160
+ echo " "
161
+ }
162
+ APP_ARGS=$(save "$@")
163
+
164
+ # Collect all arguments for the java command, following the shell quoting and substitution rules
165
+ eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166
+
167
+ # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168
+ if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169
+ cd "$(dirname "$0")"
170
+ fi
171
+
172
+ exec "$JAVACMD" "$@"
data/gradlew.bat ADDED
@@ -0,0 +1,84 @@
1
+ @if "%DEBUG%" == "" @echo off
2
+ @rem ##########################################################################
3
+ @rem
4
+ @rem Gradle startup script for Windows
5
+ @rem
6
+ @rem ##########################################################################
7
+
8
+ @rem Set local scope for the variables with windows NT shell
9
+ if "%OS%"=="Windows_NT" setlocal
10
+
11
+ set DIRNAME=%~dp0
12
+ if "%DIRNAME%" == "" set DIRNAME=.
13
+ set APP_BASE_NAME=%~n0
14
+ set APP_HOME=%DIRNAME%
15
+
16
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
+ set DEFAULT_JVM_OPTS=
18
+
19
+ @rem Find java.exe
20
+ if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+ set JAVA_EXE=java.exe
23
+ %JAVA_EXE% -version >NUL 2>&1
24
+ if "%ERRORLEVEL%" == "0" goto init
25
+
26
+ echo.
27
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+ echo.
29
+ echo Please set the JAVA_HOME variable in your environment to match the
30
+ echo location of your Java installation.
31
+
32
+ goto fail
33
+
34
+ :findJavaFromJavaHome
35
+ set JAVA_HOME=%JAVA_HOME:"=%
36
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+ if exist "%JAVA_EXE%" goto init
39
+
40
+ echo.
41
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+ echo.
43
+ echo Please set the JAVA_HOME variable in your environment to match the
44
+ echo location of your Java installation.
45
+
46
+ goto fail
47
+
48
+ :init
49
+ @rem Get command-line arguments, handling Windows variants
50
+
51
+ if not "%OS%" == "Windows_NT" goto win9xME_args
52
+
53
+ :win9xME_args
54
+ @rem Slurp the command line arguments.
55
+ set CMD_LINE_ARGS=
56
+ set _SKIP=2
57
+
58
+ :win9xME_args_slurp
59
+ if "x%~1" == "x" goto execute
60
+
61
+ set CMD_LINE_ARGS=%*
62
+
63
+ :execute
64
+ @rem Setup the command line
65
+
66
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67
+
68
+ @rem Execute Gradle
69
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70
+
71
+ :end
72
+ @rem End local scope for the variables with windows NT shell
73
+ if "%ERRORLEVEL%"=="0" goto mainEnd
74
+
75
+ :fail
76
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77
+ rem the _cmd.exe /c_ return code!
78
+ if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79
+ exit /b 1
80
+
81
+ :mainEnd
82
+ if "%OS%"=="Windows_NT" endlocal
83
+
84
+ :omega
@@ -0,0 +1,3 @@
1
+ Embulk::JavaPlugin.register_input(
2
+ "athena", "org.embulk.input.athena.AthenaInputPlugin",
3
+ File.expand_path('../../../../classpath', __FILE__))
@@ -0,0 +1,49 @@
1
+ package org.embulk.input.athena;
2
+
3
+ import java.util.List;
4
+ import java.sql.Connection;
5
+ import java.sql.PreparedStatement;
6
+ import java.sql.SQLException;
7
+ import java.sql.ResultSet;
8
+
9
+ import org.embulk.input.jdbc.JdbcInputConnection;
10
+ import org.embulk.input.jdbc.JdbcLiteral;
11
+ import org.embulk.input.jdbc.getter.ColumnGetter;
12
+
13
+ public class AthenaInputConnection
14
+ extends JdbcInputConnection
15
+ {
16
+ public AthenaInputConnection(Connection connection)
17
+ throws SQLException
18
+ {
19
+ super(connection, null);
20
+ }
21
+
22
+ @Override
23
+ protected BatchSelect newBatchSelect(PreparedQuery preparedQuery,
24
+ List<ColumnGetter> getters,
25
+ int fetchRows, int queryTimeout) throws SQLException
26
+ {
27
+ String query = preparedQuery.getQuery();
28
+ List<JdbcLiteral> params = preparedQuery.getParameters();
29
+
30
+ logger.info("SQL: " + query);
31
+ PreparedStatement stmt = connection.prepareStatement(query, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); // TYPE_FORWARD_ONLY and CONCUR_READ_ONLY are default
32
+ if (!params.isEmpty()) {
33
+ logger.info("Parameters: {}", params);
34
+ prepareParameters(stmt, getters, params);
35
+ }
36
+ if (fetchRows == 1) {
37
+ // See MySQLInputPlugin.newConnection doesn't set useCursorFetch=true when fetchRows=1
38
+ // MySQL Connector/J keeps the connection opened and process rows one by one with Integer.MIN_VALUE.
39
+ stmt.setFetchSize(Integer.MIN_VALUE);
40
+ } else if (fetchRows <= 0) {
41
+ // uses the default behavior. MySQL Connector/J fetches the all rows in memory.
42
+ } else {
43
+ // useCursorFetch=true is enabled. MySQL creates temporary table and uses multiple select statements to fetch rows.
44
+ stmt.setFetchSize(fetchRows);
45
+ }
46
+ // Because socketTimeout is set in Connection, don't need to set quertyTimeout.
47
+ return new SingleSelect(stmt);
48
+ }
49
+ }
@@ -0,0 +1,202 @@
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.ResultSetMetaData;
7
+ import java.sql.SQLException;
8
+ import java.sql.Statement;
9
+ import java.util.List;
10
+ import java.util.Properties;
11
+
12
+ import org.embulk.config.Config;
13
+ import org.embulk.config.ConfigDefault;
14
+ import org.embulk.config.ConfigDiff;
15
+ import org.embulk.config.ConfigInject;
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.ToStringMap;
21
+ import org.embulk.spi.BufferAllocator;
22
+ import org.embulk.spi.Column;
23
+ import org.embulk.spi.ColumnVisitor;
24
+ import org.embulk.spi.Exec;
25
+ import org.embulk.spi.InputPlugin;
26
+ import org.embulk.spi.PageBuilder;
27
+ import org.embulk.spi.PageOutput;
28
+ import org.embulk.spi.Schema;
29
+ import org.embulk.spi.SchemaConfig;
30
+ import org.embulk.spi.time.Timestamp;
31
+
32
+ public class AthenaInputPlugin implements InputPlugin {
33
+ public interface PluginTask extends Task {
34
+ // database (required string)
35
+ @Config("database")
36
+ public String getDatabase();
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
+ // query (required string)
55
+ @Config("query")
56
+ public String getQuery();
57
+
58
+ // if you get schema from config
59
+ @Config("columns")
60
+ public SchemaConfig getColumns();
61
+
62
+ @Config("options")
63
+ @ConfigDefault("{}")
64
+ public ToStringMap getOptions();
65
+
66
+ @ConfigInject
67
+ BufferAllocator getBufferAllocator();
68
+ }
69
+
70
+ @Override
71
+ public ConfigDiff transaction(ConfigSource config, InputPlugin.Control control) {
72
+ PluginTask task = config.loadConfig(PluginTask.class);
73
+
74
+ Schema schema = task.getColumns().toSchema();
75
+ int taskCount = 1; // number of run() method calls
76
+
77
+ return resume(task.dump(), schema, taskCount, control);
78
+ }
79
+
80
+ @Override
81
+ public ConfigDiff resume(TaskSource taskSource, Schema schema, int taskCount, InputPlugin.Control control) {
82
+ control.run(taskSource, schema, taskCount);
83
+ return Exec.newConfigDiff();
84
+ }
85
+
86
+ @Override
87
+ public void cleanup(TaskSource taskSource, Schema schema, int taskCount, List<TaskReport> successTaskReports) {
88
+ }
89
+
90
+ @Override
91
+ public TaskReport run(TaskSource taskSource, Schema schema, int taskIndex, PageOutput output) {
92
+ PluginTask task = taskSource.loadTask(PluginTask.class);
93
+ BufferAllocator allocator = task.getBufferAllocator();
94
+ PageBuilder pageBuilder = new PageBuilder(allocator, schema, output);
95
+
96
+ // Write your code here :)
97
+
98
+ Connection connection = null;
99
+ Statement statement = null;
100
+ try {
101
+ connection = getAthenaConnection(task);
102
+ statement = connection.createStatement();
103
+ ResultSet resultSet = statement.executeQuery(task.getQuery());
104
+
105
+ ResultSetMetaData m = resultSet.getMetaData();
106
+ while (resultSet.next()) {
107
+ schema.visitColumns(new ColumnVisitor() {
108
+ @Override
109
+ public void timestampColumn(Column column) {
110
+ try {
111
+ java.sql.Timestamp t = resultSet.getTimestamp(column.getName());
112
+ pageBuilder.setTimestamp(column, Timestamp.ofEpochMilli(t.getTime()));
113
+ } catch (SQLException e) {
114
+ e.printStackTrace();
115
+ }
116
+ }
117
+
118
+ @Override
119
+ public void stringColumn(Column column) {
120
+ try {
121
+ pageBuilder.setString(column, resultSet.getString(column.getName()));
122
+ } catch (SQLException e) {
123
+ e.printStackTrace();
124
+ }
125
+ }
126
+
127
+ @Override
128
+ public void longColumn(Column column) {
129
+ try {
130
+ pageBuilder.setLong(column, resultSet.getLong(column.getName()));
131
+ } catch (SQLException e) {
132
+ e.printStackTrace();
133
+ }
134
+ }
135
+
136
+ @Override
137
+ public void doubleColumn(Column column) {
138
+ try {
139
+ pageBuilder.setDouble(column, resultSet.getDouble(column.getName()));
140
+ } catch (SQLException e) {
141
+ e.printStackTrace();
142
+ }
143
+ }
144
+
145
+ @Override
146
+ public void booleanColumn(Column column) {
147
+ try {
148
+ pageBuilder.setBoolean(column, resultSet.getBoolean(column.getName()));
149
+ } catch (SQLException e) {
150
+ e.printStackTrace();
151
+ }
152
+ }
153
+
154
+ @Override
155
+ public void jsonColumn(Column column) {
156
+ // TODO:
157
+ }
158
+ });
159
+
160
+ pageBuilder.addRecord();
161
+ }
162
+ pageBuilder.finish();
163
+
164
+ pageBuilder.close();
165
+ resultSet.close();
166
+ connection.close();
167
+ } catch (Exception e) {
168
+ e.printStackTrace();
169
+ } finally {
170
+ try {
171
+ if (statement != null)
172
+ statement.close();
173
+ } catch (Exception ex) {
174
+
175
+ }
176
+ try {
177
+ if (connection != null)
178
+ connection.close();
179
+ } catch (Exception ex) {
180
+ ex.printStackTrace();
181
+ }
182
+ }
183
+
184
+ return Exec.newTaskReport();
185
+ }
186
+
187
+ @Override
188
+ public ConfigDiff guess(ConfigSource config) {
189
+ return Exec.newConfigDiff();
190
+ }
191
+
192
+ protected Connection getAthenaConnection(PluginTask task) throws ClassNotFoundException, SQLException {
193
+ Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");
194
+ Properties properties = new Properties();
195
+ properties.put("s3_staging_dir", task.getS3StagingDir());
196
+ properties.put("user", task.getAccessKey());
197
+ properties.put("password", task.getSecretKey());
198
+ properties.putAll(task.getOptions());
199
+
200
+ return DriverManager.getConnection(task.getAthenaUrl(), properties);
201
+ }
202
+ }