You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2019/10/19 00:01:28 UTC

[incubator-iceberg] branch master updated: Use OutputFile.location to track metadata JSON files (#566)

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 706c777  Use OutputFile.location to track metadata JSON files (#566)
706c777 is described below

commit 706c7772d6f6151a04be883d10d49f3d49adf63d
Author: Anton Okolnychyi <ao...@apple.com>
AuthorDate: Sat Oct 19 01:01:20 2019 +0100

    Use OutputFile.location to track metadata JSON files (#566)
---
 .../iceberg/BaseMetastoreTableOperations.java      |  2 +-
 .../iceberg/hive/HiveCreateReplaceTableTest.java   | 24 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java b/core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java
index 45b6047..6358731 100644
--- a/core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java
+++ b/core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java
@@ -120,7 +120,7 @@ public abstract class BaseMetastoreTableOperations implements TableOperations {
     // always unique because it includes a UUID.
     TableMetadataParser.overwrite(metadata, newMetadataLocation);
 
-    return newTableMetadataFilePath;
+    return newMetadataLocation.location();
   }
 
   protected void refreshFromMetadataLocation(String newLocation) {
diff --git a/hive/src/test/java/org/apache/iceberg/hive/HiveCreateReplaceTableTest.java b/hive/src/test/java/org/apache/iceberg/hive/HiveCreateReplaceTableTest.java
index d69b02c..c8406a3 100644
--- a/hive/src/test/java/org/apache/iceberg/hive/HiveCreateReplaceTableTest.java
+++ b/hive/src/test/java/org/apache/iceberg/hive/HiveCreateReplaceTableTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.iceberg.hive;
 
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
 import java.io.IOException;
 import org.apache.iceberg.AppendFiles;
@@ -279,4 +280,27 @@ public class HiveCreateReplaceTableTest extends HiveMetastoreTest {
     Assert.assertEquals("Partition spec should match", PartitionSpec.unpartitioned(), table.spec());
     Assert.assertEquals("Table props should match", "value", table.properties().get("prop"));
   }
+
+  @Test
+  public void testCreateTableTxnWithGlobalTableLocation() {
+    Assert.assertFalse("Table should not exist", catalog.tableExists(TABLE_IDENTIFIER));
+
+    Transaction txn = catalog.newCreateTableTransaction(
+        TABLE_IDENTIFIER, SCHEMA, SPEC, "file:///" + tableLocation, Maps.newHashMap());
+    txn.commitTransaction();
+
+    Table table = catalog.loadTable(TABLE_IDENTIFIER);
+
+    DataFile dataFile = DataFiles.builder(SPEC)
+        .withPath("/path/to/data-a.parquet")
+        .withFileSizeInBytes(0)
+        .withRecordCount(1)
+        .build();
+
+    table.newAppend()
+        .appendFile(dataFile)
+        .commit();
+
+    Assert.assertEquals("Write should succeed", 1, Iterables.size(table.snapshots()));
+  }
 }