This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 51eb225 Hadoop catalog: Allow empty namespaces (#878)
51eb225 is described below
commit 51eb225822adfac3515d9a5046f34d5ecd8af184
Author: Chen, Junjie <[email protected]>
AuthorDate: Wed Apr 1 00:45:13 2020 +0800
Hadoop catalog: Allow empty namespaces (#878)
---
.../org/apache/iceberg/catalog/TableIdentifier.java | 6 +++++-
.../org/apache/iceberg/hadoop/HadoopCatalog.java | 2 +-
.../apache/iceberg/hadoop/TestHadoopCatalog.java | 21 +++++++++++++++++++++
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/api/src/main/java/org/apache/iceberg/catalog/TableIdentifier.java
b/api/src/main/java/org/apache/iceberg/catalog/TableIdentifier.java
index 752b1af..7e30c8f 100644
--- a/api/src/main/java/org/apache/iceberg/catalog/TableIdentifier.java
+++ b/api/src/main/java/org/apache/iceberg/catalog/TableIdentifier.java
@@ -106,6 +106,10 @@ public class TableIdentifier {
@Override
public String toString() {
- return namespace.toString() + "." + name;
+ if (hasNamespace()) {
+ return namespace.toString() + "." + name;
+ } else {
+ return name;
+ }
}
}
diff --git a/core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java
b/core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java
index 644a627..04b8747 100644
--- a/core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java
+++ b/core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java
@@ -143,7 +143,7 @@ public class HadoopCatalog extends BaseMetastoreCatalog
implements Closeable {
@Override
protected boolean isValidIdentifier(TableIdentifier identifier) {
- return identifier.namespace().levels().length >= 1;
+ return true;
}
@Override
diff --git
a/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCatalog.java
b/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCatalog.java
index 18c5650..1e86720 100644
--- a/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCatalog.java
@@ -29,6 +29,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.iceberg.AssertHelpers;
import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Table;
import org.apache.iceberg.Transaction;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.TableIdentifier;
@@ -54,6 +55,26 @@ public class TestHadoopCatalog extends HadoopTableTestBase {
}
@Test
+ public void testCreateAndDropTableWithoutNamespace() throws Exception {
+ Configuration conf = new Configuration();
+ String warehousePath = temp.newFolder().getAbsolutePath();
+ HadoopCatalog catalog = new HadoopCatalog(conf, warehousePath);
+
+ TableIdentifier testTable = TableIdentifier.of("tbl");
+ Table table = catalog.createTable(testTable, SCHEMA,
PartitionSpec.unpartitioned());
+
+ Assert.assertEquals(table.schema().toString(), TABLE_SCHEMA.toString());
+ Assert.assertEquals("hadoop.tbl", table.toString());
+ String metaLocation = catalog.defaultWarehouseLocation(testTable);
+
+ FileSystem fs = Util.getFs(new Path(metaLocation), conf);
+ Assert.assertTrue(fs.isDirectory(new Path(metaLocation)));
+
+ catalog.dropTable(testTable);
+ Assert.assertFalse(fs.isDirectory(new Path(metaLocation)));
+ }
+
+ @Test
public void testDropTable() throws Exception {
Configuration conf = new Configuration();
String warehousePath = temp.newFolder().getAbsolutePath();