Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ public Collection<Table> extract(Connection target, java.sql.Connection connecti
return tables;
}

private void attachTableType(Collection<Table> tables, java.sql.Connection connection) throws SQLException {
ResultSet resultSet = connection.createStatement().executeQuery("SELECT object_name, schema_name, shard_kind, persistence FROM ki_catalog.ki_objects;");

while (resultSet.next()) {
String object_schema = resultSet.getString("schema_name");
String object_name = resultSet.getString("object_name");
Optional<Table> found_table = tables.stream().filter(table -> table.getSchema().equals(object_schema) && table.getName().equals(object_name)).findFirst();
if (found_table.isPresent()) {
found_table.get().addProperty("shard_kind", resultSet.getString("shard_kind"));
found_table.get().addProperty("persistence", resultSet.getString("persistence"));
private void attachTableType(Collection<Table> tables, java.sql.Connection connection) {
try (Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT object_name, schema_name, shard_kind, persistence FROM ki_catalog.ki_objects;")) {

while (resultSet.next()) {
String object_schema = resultSet.getString("schema_name");
String object_name = resultSet.getString("object_name");
Optional<Table> found_table = tables.stream().filter(table -> table.getSchema().equals(object_schema) && table.getName().equals(object_name)).findFirst();
if (found_table.isPresent()) {
found_table.get().addProperty("shard_kind", resultSet.getString("shard_kind"));
found_table.get().addProperty("persistence", resultSet.getString("persistence"));
}
}
}

if (!resultSet.isClosed()) {
resultSet.close();
} catch (SQLException e) {
log.warn("Could not attach table type (shard_kind, persistence) from ki_catalog.ki_objects. " +
"Extraction will continue without these properties.");
}
}

Expand Down
Loading