forked from shinji19/embulk-input-athena
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from trocco-io/feature/complement_columns
Enable the creation of a schema taken from the table metadata and column_options
- Loading branch information
Showing
3 changed files
with
140 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/org/embulk/input/athena/getter/AthenaColumnGetterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.embulk.input.athena.getter; | ||
|
||
import org.embulk.input.jdbc.JdbcColumn; | ||
import org.embulk.input.jdbc.getter.ColumnGetterFactory; | ||
import org.embulk.spi.PageBuilder; | ||
|
||
import java.time.ZoneId; | ||
|
||
import static java.util.Locale.ENGLISH; | ||
|
||
public class AthenaColumnGetterFactory extends ColumnGetterFactory { | ||
public AthenaColumnGetterFactory(PageBuilder to, ZoneId defaultTimeZone) { | ||
super(to, defaultTimeZone); | ||
} | ||
|
||
@Override | ||
protected String sqlTypeToValueType(JdbcColumn column, int sqlType) { | ||
try { | ||
return super.sqlTypeToValueType(column, sqlType); | ||
} catch (UnsupportedOperationException e) { | ||
throw new UnsupportedOperationException( | ||
String.format(ENGLISH, | ||
"Unsupported type %s (sqlType=%d) of '%s' column. Please add '%s: {value_type: string}' to 'column_options: {...}' option to convert the values to strings.", | ||
column.getTypeName(), column.getSqlType(), column.getName(), column.getName())); | ||
} | ||
} | ||
} |