jackye1995 commented on a change in pull request #4099:
URL: https://github.com/apache/iceberg/pull/4099#discussion_r805204222
##########
File path:
aws/src/integration/java/org/apache/iceberg/aws/glue/TestGlueCatalogTable.java
##########
@@ -364,4 +367,75 @@ public void testColumnCommentsAndParameters() {
);
Assert.assertEquals("Columns do not match", expectedColumns,
actualColumns);
}
+
+ @Test
+ public void testRegisterTable() {
+ String namespace = createNamespace();
+ String tableName = getRandomName();
+ createTable(namespace, tableName);
+ Table table = glueCatalog.loadTable(TableIdentifier.of(namespace,
tableName));
+ DataFile dataFile = DataFiles.builder(partitionSpec)
+ .withPath("/path/to/data-a.parquet")
+ .withFileSizeInBytes(10)
+ .withRecordCount(1)
+ .build();
+ table.newAppend().appendFile(dataFile).commit();
+ table.refresh();
+ long v1SnapshotId = table.currentSnapshot().snapshotId();
+ String v1MetadataLocation = ((BaseTable)
table).operations().current().metadataFileLocation();
+ table.newDelete().deleteFile(dataFile).commit();
+ table.refresh();
+
+ String registeredTableName = getRandomName();
+ Table registeredTable = glueCatalog.registerTable(
+ TableIdentifier.of(namespace, registeredTableName),
v1MetadataLocation);
+
+ Assert.assertEquals("registered table should have v1 snapshot ID",
+ v1SnapshotId, registeredTable.currentSnapshot().snapshotId());
+
+ Assert.assertNotEquals("registered table should have a different snapshot
ID from the original table",
+ table.currentSnapshot().snapshotId(),
registeredTable.currentSnapshot().snapshotId());
+
+ Assert.assertEquals("Registered table should have 1 data file",
+ 1, Lists.newArrayList(registeredTable.newScan().planFiles()).size());
+
+ // check table in Glue
+ GetTableResponse response = glue.getTable(GetTableRequest.builder()
+ .databaseName(namespace).name(registeredTableName).build());
+ Assert.assertEquals("Table type should be set",
+ GlueTableOperations.GLUE_EXTERNAL_TABLE_TYPE,
response.table().tableType());
+ Assert.assertNull("Storage descriptor should be empty",
response.table().storageDescriptor());
+ Assert.assertTrue("Partition spec should be empty",
response.table().partitionKeys().isEmpty());
Review comment:
you are right, updating
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]