This is an automated email from the ASF dual-hosted git repository.
fanng pushed a commit to branch branch-0.6
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-0.6 by this push:
new d2923ec38 [#4542] fix(catalog-postgresql): Fix the problem that
Gravitino is unable to drop upper-case PG schema. (#4549)
d2923ec38 is described below
commit d2923ec389954da88e8099770fcb73ff05456bc9
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Aug 16 10:10:39 2024 +0800
[#4542] fix(catalog-postgresql): Fix the problem that Gravitino is unable
to drop upper-case PG schema. (#4549)
### 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.
Co-authored-by: Qi Yu <[email protected]>
---
.../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() {