Skip to content

Commit

Permalink
Use OutputFile.location to track metadata JSON files (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
aokolnychyi authored and shardulm94 committed Oct 21, 2019
1 parent 798ba1f commit 3bc1946
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected String writeNewMetadata(TableMetadata metadata, int newVersion) {
// always unique because it includes a UUID.
TableMetadataParser.overwrite(metadata, newMetadataLocation);

return newTableMetadataFilePath;
return newMetadataLocation.location();
}

protected void refreshFromMetadataLocation(String newLocation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -279,4 +280,27 @@ public void testCreateOrReplaceTableTxnTableCreatedConcurrently() {
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()));
}
}

0 comments on commit 3bc1946

Please sign in to comment.