use of com.github.jcustenborder.vertica.VerticaColumnType in project kafka-connect-vertica by jcustenborder.
the class VerticaSinkTask method configureBuilder.
VerticaStreamWriterBuilder configureBuilder(Connection connection, final String tableName) throws ExecutionException {
return this.builderCache.get(tableName, () -> {
VerticaStreamWriterBuilder builder = new VerticaStreamWriterBuilder();
builder.compressionType(this.config.compressionType);
builder.loadMethod(this.config.loadMethod);
builder.table(tableName);
log.trace("configureBuilder() - Finding columns for '{}'", tableName);
List<String> fields = new ArrayList<>();
try (PreparedStatement statement = connection.prepareStatement(SQL)) {
statement.setString(1, tableName);
try (ResultSet results = statement.executeQuery()) {
while (results.next()) {
String columnName = results.getString(1);
fields.add(columnName);
String dataType = results.getString(2);
Matcher matcher = PATTERN.matcher(dataType);
if (!matcher.find()) {
log.warn("Could not match '{}' for column '{}'", dataType, columnName);
continue;
}
String stype = matcher.group(0).toUpperCase();
VerticaColumnType type = VerticaColumnType.valueOf(stype);
log.info("configureBuilder() - '{}' = {}", columnName, type);
builder.column(columnName, type);
}
}
}
return builder;
});
}
Aggregations