diqiu50 commented on code in PR #10383:
URL: https://github.com/apache/gravitino/pull/10383#discussion_r2964434561


##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseDatabaseOperations.java:
##########
@@ -124,12 +127,65 @@ public void create(String databaseName, String comment, 
Map<String, String> prop
   protected void dropDatabase(String databaseName, boolean cascade) {
     try (final Connection connection = getConnection()) {
       connection.setCatalog(createSysDatabaseNameSet().iterator().next());
-      JdbcConnectorUtils.executeUpdate(connection, 
generateDropDatabaseSql(databaseName, cascade));
+      if (!cascade) {
+        try (Statement stmt = connection.createStatement();
+            ResultSet rs = stmt.executeQuery(String.format("SHOW TABLES IN 
`%s`", databaseName))) {

Review Comment:
   Querying system table does not handle this case too.  you'd better Add some 
comments



##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseClusterUtils.java:
##########
@@ -36,11 +36,60 @@
  *   <li>{@code system.databases.cluster} is only populated for {@code 
Replicated}-engine databases.
  * </ul>
  *
- * <p>Gravitino therefore embeds the cluster name inside the object's COMMENT 
field at creation time
- * using a non-printable SOH separator ({@code \u0001}). The metadata is 
invisible to end users
- * because Gravitino strips it before surfacing the comment.
+ * <p>Gravitino therefore embeds the cluster name inside the object's COMMENT 
field at creation
+ * time, separated from the user comment by a newline. The metadata line is 
always stripped before
+ * surfacing the comment to callers.
  *
- * <p><b>Stored format:</b> {@code userComment\u0001ch.cluster=clusterName}
+ * <p><b>Stored format:</b>
+ *
+ * <pre>userComment
+ * [Gravitino] ch.cluster=clusterName</pre>
+ *
+ * <p><b>Example — database created ON CLUSTER:</b>
+ *
+ * <pre>
+ * -- Gravitino issues:
+ * CREATE DATABASE `my_db` ON CLUSTER `ck_cluster`
+ *   COMMENT 'my comment\n[Gravitino] ch.cluster=ck_cluster'
+ *
+ * -- ClickHouse SHOW CREATE DATABASE output (ON CLUSTER is omitted):
+ * CREATE DATABASE my_db
+ * ENGINE = Atomic
+ * COMMENT 'my comment
+ * [Gravitino] ch.cluster=ck_cluster'
+ *
+ * -- Gravitino reads back from system.databases.comment:
+ * --   stored : 'my comment\n[Gravitino] ch.cluster=ck_cluster'
+ * --   cluster: 'ck_cluster'   (extracted by extractClusterFromComment)
+ * --   user   : 'my comment'   (stripped by stripClusterMetadata)
+ * </pre>
+ *
+ * <p><b>Example — table created ON CLUSTER:</b>
+ *
+ * <pre>
+ * -- Gravitino issues:
+ * CREATE TABLE `orders` ON CLUSTER `ck_cluster`
+ *   (`id` Int32, `amount` Decimal(10,2))
+ *   ENGINE = MergeTree()
+ *   ORDER BY `id`
+ *   COMMENT 'order records\n[Gravitino] ch.cluster=ck_cluster'
+ *

Review Comment:
   Do we need an end marker?



-- 
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