mchades commented on code in PR #5013:
URL: https://github.com/apache/gravitino/pull/5013#discussion_r1776763918


##########
catalogs/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/operation/OceanBaseDatabaseOperations.java:
##########
@@ -41,25 +47,56 @@ private static Set<String> 
createSysOceanBaseDatabaseNames() {
     return Collections.unmodifiableSet(set);
   }
 
-  @Override
-  public String generateCreateDatabaseSql(
-      String databaseName, String comment, Map<String, String> properties) {
-
-    throw new UnsupportedOperationException("Not implemented yet.");
-  }
-
   @Override
   public String generateDropDatabaseSql(String databaseName, boolean cascade) {
-    throw new UnsupportedOperationException("Not implemented yet.");
+    final String dropDatabaseSql = String.format("DROP DATABASE `%s`", 
databaseName);
+    if (cascade) {
+      return dropDatabaseSql;
+    }
+
+    try (final Connection connection = this.dataSource.getConnection()) {
+      String query = String.format("SHOW TABLES IN `%s`", databaseName);
+      try (Statement statement = connection.createStatement()) {
+        // Execute the query and check if there exists any tables in the 
database
+        try (ResultSet resultSet = statement.executeQuery(query)) {
+          if (resultSet.next()) {
+            throw new IllegalStateException(
+                String.format(
+                    "Database %s is not empty, the value of cascade should be 
true.",
+                    databaseName));
+          }
+        }
+      }
+    } catch (SQLException sqlException) {
+      throw this.exceptionMapper.toGravitinoException(sqlException);
+    }
+    return dropDatabaseSql;
   }
 
   @Override
   public JdbcSchema load(String databaseName) throws NoSuchSchemaException {
-    throw new UnsupportedOperationException("Not implemented yet.");
+    List<String> allDatabases = listDatabases();

Review Comment:
   also this



##########
catalogs/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/operation/OceanBaseDatabaseOperations.java:
##########
@@ -41,25 +47,56 @@ private static Set<String> 
createSysOceanBaseDatabaseNames() {
     return Collections.unmodifiableSet(set);
   }
 
-  @Override
-  public String generateCreateDatabaseSql(
-      String databaseName, String comment, Map<String, String> properties) {
-
-    throw new UnsupportedOperationException("Not implemented yet.");
-  }
-
   @Override
   public String generateDropDatabaseSql(String databaseName, boolean cascade) {
-    throw new UnsupportedOperationException("Not implemented yet.");
+    final String dropDatabaseSql = String.format("DROP DATABASE `%s`", 
databaseName);

Review Comment:
   Can this method be reused?



##########
catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/operation/JdbcDatabaseOperations.java:
##########
@@ -114,8 +115,15 @@ protected void dropDatabase(String databaseName, boolean 
cascade) {
    * @param properties The properties of the database.
    * @return the SQL statement to create a database with the given name and 
comment.
    */
-  protected abstract String generateCreateDatabaseSql(
-      String databaseName, String comment, Map<String, String> properties);
+  protected String generateCreateDatabaseSql(

Review Comment:
   Please add comments to indicate that this is the default implementation of 
MySQL syntax, and if the catalog does not support MySQL syntax, this method 
needs to be rewritten.



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