in athena-jdbc/src/main/java/com/amazonaws/athena/connectors/jdbc/manager/JdbcRecordHandler.java [195:290]
private Extractor makeExtractor(Field field, ResultSet resultSet, Map<String, String> partitionValues)
{
Types.MinorType fieldType = Types.getMinorTypeForArrowType(field.getType());
final String fieldName = field.getName();
if (partitionValues.containsKey(fieldName)) {
return (VarCharExtractor) (Object context, NullableVarCharHolder dst) ->
{
dst.isSet = 1;
dst.value = partitionValues.get(fieldName);
};
}
switch (fieldType) {
case BIT:
return (BitExtractor) (Object context, NullableBitHolder dst) ->
{
boolean value = resultSet.getBoolean(fieldName);
dst.value = value ? 1 : 0;
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case TINYINT:
return (TinyIntExtractor) (Object context, NullableTinyIntHolder dst) ->
{
dst.value = resultSet.getByte(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case SMALLINT:
return (SmallIntExtractor) (Object context, NullableSmallIntHolder dst) ->
{
dst.value = resultSet.getShort(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case INT:
return (IntExtractor) (Object context, NullableIntHolder dst) ->
{
dst.value = resultSet.getInt(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case BIGINT:
return (BigIntExtractor) (Object context, NullableBigIntHolder dst) ->
{
dst.value = resultSet.getLong(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case FLOAT4:
return (Float4Extractor) (Object context, NullableFloat4Holder dst) ->
{
dst.value = resultSet.getFloat(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case FLOAT8:
return (Float8Extractor) (Object context, NullableFloat8Holder dst) ->
{
dst.value = resultSet.getDouble(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case DECIMAL:
return (DecimalExtractor) (Object context, NullableDecimalHolder dst) ->
{
dst.value = resultSet.getBigDecimal(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case DATEDAY:
return (DateDayExtractor) (Object context, NullableDateDayHolder dst) ->
{
if (resultSet.getDate(fieldName) != null) {
dst.value = (int) TimeUnit.MILLISECONDS.toDays(resultSet.getDate(fieldName).getTime());
}
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case DATEMILLI:
return (DateMilliExtractor) (Object context, NullableDateMilliHolder dst) ->
{
if (resultSet.getTimestamp(fieldName) != null) {
dst.value = resultSet.getTimestamp(fieldName).getTime();
}
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case VARCHAR:
return (VarCharExtractor) (Object context, NullableVarCharHolder dst) ->
{
dst.value = resultSet.getString(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
case VARBINARY:
return (VarBinaryExtractor) (Object context, NullableVarBinaryHolder dst) ->
{
dst.value = resultSet.getBytes(fieldName);
dst.isSet = resultSet.wasNull() ? 0 : 1;
};
default:
throw new RuntimeException("Unhandled type " + fieldType);
}
}