pvary commented on a change in pull request #2219:
URL: https://github.com/apache/hive/pull/2219#discussion_r620254521



##########
File path: 
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java
##########
@@ -955,4 +1046,44 @@ private void validateBasicStats(Table icebergTable, 
String dbName, String tableN
       Assert.assertEquals(summary.get(entry.getValue()), 
hmsParams.get(entry.getKey()));
     }
   }
+
+  private void validateMigration(String tableName, int recordCount) {
+    List<Object[]> originalResult = shell.executeStatement("SELECT * FROM " + 
tableName + " ORDER BY a");
+    Assert.assertEquals(recordCount, originalResult.size());
+    List<Object[]> originalDescribe = shell.executeStatement("DESCRIBE 
FORMATTED " + tableName);
+    validateDescribeOutput(originalDescribe, fileFormat.name());
+    shell.executeStatement("ALTER TABLE " + tableName + " SET TBLPROPERTIES " +
+        
"('storage_handler'='org.apache.iceberg.mr.hive.HiveIcebergStorageHandler')");
+    List<Object[]> alterResult = shell.executeStatement("SELECT * FROM " + 
tableName + " ORDER BY a");
+    Assert.assertEquals(originalResult.size(), alterResult.size());
+    List<Object[]> alterDescribe = shell.executeStatement("DESCRIBE FORMATTED 
" + tableName);
+    validateDescribeOutput(alterDescribe, "iceberg");
+  }
+
+  private void validateMigrationRollback(String tableName, int recordCount) {
+    List<Object[]> originalResult = shell.executeStatement("SELECT * FROM " + 
tableName + " ORDER BY a");
+    Assert.assertEquals(recordCount, originalResult.size());
+    List<Object[]> originalDescribe = shell.executeStatement("DESCRIBE 
FORMATTED " + tableName);
+    validateDescribeOutput(originalDescribe, fileFormat.name());
+    try (MockedStatic<HiveTableUtil> mockedTableUtil = 
Mockito.mockStatic(HiveTableUtil.class)) {
+      mockedTableUtil.when(() -> 
HiveTableUtil.importFiles(ArgumentMatchers.anyString(), 
ArgumentMatchers.anyString(),
+          ArgumentMatchers.any(PartitionSpecProxy.class), 
ArgumentMatchers.anyList(),
+          ArgumentMatchers.any(Properties.class), 
ArgumentMatchers.any(Configuration.class)))
+          .thenThrow(new MetaException());
+      shell.executeStatement("ALTER TABLE " + tableName + " SET TBLPROPERTIES 
" +
+          
"('storage_handler'='org.apache.iceberg.mr.hive.HiveIcebergStorageHandler')");
+      List<Object[]> alterResult = shell.executeStatement("SELECT * FROM " + 
tableName + " ORDER BY a");
+      Assert.assertEquals(originalResult.size(), alterResult.size());
+      List<Object[]> alterDescribe = shell.executeStatement("DESCRIBE 
FORMATTED " + tableName);
+      validateDescribeOutput(alterDescribe, fileFormat.name());
+    }
+  }
+
+  private void validateDescribeOutput(List<Object[]> describe, String format) {

Review comment:
       What does this validation check?




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to