This is an automated email from the ASF dual-hosted git repository.

yuqi4733 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 44edf286e [#4542] fix(catalog-postgresql): Fix the problem that 
Gravitino is unable to drop upper-case PG schema. (#4543)
44edf286e is described below

commit 44edf286e966141521c2155bbb2bb2107d6f8acb
Author: Qi Yu <[email protected]>
AuthorDate: Fri Aug 16 09:09:20 2024 +0800

    [#4542] fix(catalog-postgresql): Fix the problem that Gravitino is unable 
to drop upper-case PG schema. (#4543)
    
    ### What changes were proposed in this pull request?
    
    Double quote the schema name in the drop sentence to support removing
    upper-case schema
    
    ### Why are the changes needed?
    
    It's a bug.
    
    Fix: #4542
    
    ### Does this PR introduce _any_ user-facing change?
    
    N/A.
    
    ### How was this patch tested?
    
    Add IT.
---
 .../postgresql/operation/PostgreSqlSchemaOperations.java      |  3 ++-
 .../postgresql/integration/test/CatalogPostgreSqlIT.java      | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
 
b/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
index 04850055a..8875ac38b 100644
--- 
a/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
+++ 
b/catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
@@ -151,7 +151,8 @@ public class PostgreSqlSchemaOperations extends 
JdbcDatabaseOperations {
 
   @Override
   public String generateDropDatabaseSql(String schema, boolean cascade) {
-    StringBuilder sqlBuilder = new StringBuilder(String.format("DROP SCHEMA 
%s", schema));
+    StringBuilder sqlBuilder =
+        new StringBuilder(String.format("DROP SCHEMA %s%s%s", PG_QUOTE, 
schema, PG_QUOTE));
     if (cascade) {
       sqlBuilder.append(" CASCADE");
     }
diff --git 
a/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java
 
b/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java
index 947538750..685e04eb3 100644
--- 
a/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java
+++ 
b/catalogs/catalog-jdbc-postgresql/src/test/java/org/apache/gravitino/catalog/postgresql/integration/test/CatalogPostgreSqlIT.java
@@ -324,6 +324,17 @@ public class CatalogPostgreSqlIT extends AbstractIT {
     Optional<Column> column =
         Arrays.stream(t.columns()).filter(c -> 
c.name().equals("binary")).findFirst();
     Assertions.assertTrue(column.isPresent());
+
+    boolean result = tableCatalog.dropTable(tableIdentifier);
+    Assertions.assertTrue(result);
+
+    Assertions.assertThrows(Exception.class, () -> 
tableCatalog.loadTable(tableIdentifier));
+
+    // Test drop schema with upper-case name
+    result = catalog.asSchemas().dropSchema(schemaN, false);
+
+    // Test whether drop the schema succussfully.
+    Assertions.assertTrue(result);
   }
 
   private Map<String, String> createProperties() {

Reply via email to