This is an automated email from the ASF dual-hosted git repository.
jshao 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 9be7cc999 [#3985] fix(hadooop-catalog): Create fileset catalog with
empty location property success, but can't list schema of the catalog (#4177)
9be7cc999 is described below
commit 9be7cc999f97fe0962a53945f95bfbd46b7e90c0
Author: liuxian <[email protected]>
AuthorDate: Thu Jul 18 15:03:50 2024 +0800
[#3985] fix(hadooop-catalog): Create fileset catalog with empty location
property success, but can't list schema of the catalog (#4177)
### What changes were proposed in this pull request?
Check if the catalogLocation is empty when initializing
### Why are the changes needed?
Fix: #3985
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Existing pipeline.
Before
<img width="1480" alt="image"
src="https://github.com/user-attachments/assets/42003bf4-f6a2-4729-98fc-bf139a811daf">
After
<img width="865" alt="image"
src="https://github.com/user-attachments/assets/531dbc3b-7ad3-4949-8910-ea99bb31baa1">
---
.../catalog/hadoop/HadoopCatalogOperations.java | 5 ++++-
.../catalog/hadoop/TestHadoopCatalogOperations.java | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git
a/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/HadoopCatalogOperations.java
b/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/HadoopCatalogOperations.java
index b82eaa359..6b49c1310 100644
---
a/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/HadoopCatalogOperations.java
+++
b/catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/HadoopCatalogOperations.java
@@ -135,7 +135,10 @@ public class HadoopCatalogOperations implements
CatalogOperations, SupportsSchem
conf.forEach(hadoopConf::set);
initAuthentication(conf, hadoopConf);
- this.catalogStorageLocation =
Optional.ofNullable(catalogLocation).map(Path::new);
+ this.catalogStorageLocation =
+ StringUtils.isNotBlank(catalogLocation)
+ ? Optional.of(catalogLocation).map(Path::new)
+ : Optional.empty();
}
private void initAuthentication(Map<String, String> conf, Configuration
hadoopConf) {
diff --git
a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java
b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java
index 284070f0b..3c8a4d463 100644
---
a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java
+++
b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java
@@ -230,6 +230,22 @@ public class TestHadoopCatalogOperations {
Assertions.assertEquals("Schema m1.c1.schema11 already exists",
exception.getMessage());
}
+ @Test
+ public void testCreateSchemaWithEmptyCatalogLocation() throws IOException {
+ String name = "schema28";
+ String comment = "comment28";
+ String catalogPath = "";
+ Schema schema = createSchema(name, comment, catalogPath, null);
+ Assertions.assertEquals(name, schema.name());
+ Assertions.assertEquals(comment, schema.comment());
+
+ Throwable exception =
+ Assertions.assertThrows(
+ SchemaAlreadyExistsException.class,
+ () -> createSchema(name, comment, catalogPath, null));
+ Assertions.assertEquals("Schema m1.c1.schema28 already exists",
exception.getMessage());
+ }
+
@Test
public void testCreateSchemaWithCatalogLocation() throws IOException {
String name = "schema12";