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


##########
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:
   Fixed.



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