Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#3326] feat(jdbc-doris): output the alter status of table into the log (#3332)

Kang6f2dba286613
diff --git a/catalogs/catalog-jdbc-doris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java b/catalogs/catalog-jdbc-doris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
index afa168c33e..27dd691286 100644
--- a/catalogs/catalog-jdbc-doris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
+++ b/catalogs/catalog-jdbc-doris/src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
@@ -249,7 +249,6 @@ public class DorisTableOperations extends JdbcTableOperations {
protected void correctJdbcTableFields(
Connection connection, String databaseName, String tableName, JdbcTable.Builder tableBuilder)
throws SQLException {
-
if (StringUtils.isNotEmpty(tableBuilder.comment())) {
return;
}
@@ -271,6 +270,48 @@ public class DorisTableOperations extends JdbcTableOperations {
} catch (SQLException e) {
throw exceptionMapper.toGravitinoException(e);
}
+
+ getTableStatus(connection, databaseName, tableName);
+ }
+
+ protected void getTableStatus(Connection connection, String databaseName, String tableName) {
+ // sql is `SHOW ALTER TABLE COLUMN WHERE TableName = 'test_table'`
+ // database name must be specified in connection, so the SQL do not need to specify database
+ // name
+ String sql =
+ String.format(
+ "SHOW ALTER TABLE COLUMN WHERE TableName = '%s' ORDER BY JobId DESC limit 1",
+ tableName);
+
+ // Just print each column name and type from resultSet
+ // TODO: add to table properties or other fields
+ try (PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
+
+ StringBuilder jobStatus = new StringBuilder();
+ while (resultSet.next()) {
+ int columnCount = resultSet.getMetaData().getColumnCount();
+ for (int i = 1; i <= columnCount; i++) {
+ jobStatus
+ .append(resultSet.getMetaData().getColumnName(i))
+ .append(" : ")
+ .append(resultSet.getString(i))
+ .append(", ");
+ }
+ jobStatus.append(" | ");
+ }
+
+ if (jobStatus.length() > 0) {
+ LOG.info(
+ "Table {}.{} schema-change execution status: {}",
+ databaseName,
+ tableName,
+ jobStatus.toString());
+ }
+
+ } catch (SQLException e) {
+ throw exceptionMapper.toGravitinoException(e);
+ }
}
@Override