yuqi1129 commented on code in PR #10068:
URL: https://github.com/apache/gravitino/pull/10068#discussion_r2894974899


##########
catalogs-contrib/catalog-jdbc-hologres/src/main/java/org/apache/gravitino/catalog/hologres/operation/HologresTableOperations.java:
##########
@@ -34,17 +68,123 @@
  * <p>Hologres is PostgreSQL-compatible, so most table operations follow 
PostgreSQL conventions.
  * However, Hologres has specific features like table properties (orientation, 
distribution_key,
  * etc.) that are handled through the WITH clause in CREATE TABLE statements.
- *
- * <p>TODO: Full implementation will be added in a follow-up PR.
  */
 public class HologresTableOperations extends JdbcTableOperations
     implements RequireDatabaseOperation {
 
-  public static final String HOLO_QUOTE = "\"";
+  public static final String NEW_LINE = "\n";
+  public static final String ALTER_TABLE = "ALTER TABLE ";
+  public static final String ALTER_COLUMN = "ALTER COLUMN ";
+  public static final String IS = " IS '";
+  public static final String COLUMN_COMMENT = "COMMENT ON COLUMN ";
+  public static final String TABLE_COMMENT = "COMMENT ON TABLE ";
+
+  private static final String HOLOGRES_NOT_SUPPORT_NESTED_COLUMN_MSG =
+      "Hologres does not support nested column names.";
+
+  /** Properties that are handled separately or read-only, excluded from the 
WITH clause. */
+  private static final Set<String> EXCLUDED_TABLE_PROPERTIES =
+      ImmutableSet.of("distribution_key", "is_logical_partitioned_table", 
"primary_key");
+
+  /** Properties that are meaningful for users, filtering out internal system 
properties. */
+  private static final Set<String> USER_RELEVANT_PROPERTIES =
+      ImmutableSet.of(
+          "orientation",
+          "clustering_key",
+          "segment_key",
+          "bitmap_columns",
+          "dictionary_encoding_columns",
+          "time_to_live_in_seconds",
+          "table_group",
+          "storage_format",
+          "binlog.level",
+          "binlog.ttl",
+          "is_logical_partitioned_table",
+          "partition_expiration_time",
+          "partition_keep_hot_window",
+          "partition_require_filter",
+          "partition_generate_binlog_window");
+
+  private String database;
+  private HologresSchemaOperations schemaOperations;
+
+  @Override
+  protected String quoteIdentifier(String identifier) {
+    return "\"" + identifier + "\"";
+  }
+
+  @Override
+  public void initialize(
+      DataSource dataSource,
+      JdbcExceptionConverter exceptionMapper,
+      JdbcTypeConverter jdbcTypeConverter,
+      JdbcColumnDefaultValueConverter jdbcColumnDefaultValueConverter,
+      Map<String, String> conf) {
+    super.initialize(
+        dataSource, exceptionMapper, jdbcTypeConverter, 
jdbcColumnDefaultValueConverter, conf);
+    database = new JdbcConfig(conf).getJdbcDatabase();
+    Preconditions.checkArgument(
+        StringUtils.isNotBlank(database),
+        "The `jdbc-database` configuration item is mandatory in Hologres.");
+  }
 
   @Override
   public void setDatabaseOperation(DatabaseOperation databaseOperation) {
-    // Will be implemented in a follow-up PR.
+    this.schemaOperations = (HologresSchemaOperations) databaseOperation;
+  }
+
+  @Override
+  public List<String> listTables(String schemaName) throws 
NoSuchSchemaException {
+    try (Connection connection = getConnection(schemaName)) {
+      if (!schemaOperations.schemaExists(connection, schemaName)) {
+        throw new NoSuchSchemaException("No such schema: %s", schemaName);
+      }
+      final List<String> names = Lists.newArrayList();
+      try (ResultSet tables = getTables(connection)) {
+        while (tables.next()) {
+          if (Objects.equals(tables.getString("TABLE_SCHEM"), schemaName)) {
+            names.add(tables.getString("TABLE_NAME"));
+          }
+        }
+      }
+      LOG.info("Finished listing tables size {} for schema name {} ", 
names.size(), schemaName);

Review Comment:
   **Nit:** `LOG.info` 在 listTables 这个频繁调用的方法里会比较 noisy,建议降为 
`LOG.debug`。同样的问题也出现在第 297 行(generateCreateTableSql)和第 498 
行(generateAlterTableSql)。



##########
catalogs-contrib/catalog-jdbc-hologres/src/main/java/org/apache/gravitino/catalog/hologres/operation/HologresTableOperations.java:
##########
@@ -34,17 +68,123 @@
  * <p>Hologres is PostgreSQL-compatible, so most table operations follow 
PostgreSQL conventions.
  * However, Hologres has specific features like table properties (orientation, 
distribution_key,
  * etc.) that are handled through the WITH clause in CREATE TABLE statements.
- *
- * <p>TODO: Full implementation will be added in a follow-up PR.
  */
 public class HologresTableOperations extends JdbcTableOperations
     implements RequireDatabaseOperation {
 
-  public static final String HOLO_QUOTE = "\"";
+  public static final String NEW_LINE = "\n";
+  public static final String ALTER_TABLE = "ALTER TABLE ";
+  public static final String ALTER_COLUMN = "ALTER COLUMN ";

Review Comment:
   **Nit:** `ALTER_COLUMN`、`IS`、`COLUMN_COMMENT`、`TABLE_COMMENT` 
这四个常量定义了但在代码里从未使用(代码里都是用 String.format 直接写的字面量)。
   
   建议要么在代码中统一使用这些常量(提高一致性),要么删除这些 dead code。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to