skywalker0618 commented on code in PR #20145:
URL: https://github.com/apache/hudi/pull/20145#discussion_r4141826540


##########
hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/TestHiveSyncTool.java:
##########
@@ -403,6 +404,37 @@ public void testHiveQLSyncWithBatchingEnabled() throws 
Exception {
         "Incremental add via parallel HiveQL batching should sync the new 
partitions");
   }
 
+  /**
+   * Hive's Driver reports a rejected statement through its response code 
rather than by throwing.
+   * A table registered with a different partition column than the one the 
sync is configured with
+   * rejects every ADD PARTITION, and the sync must fail instead of recording 
the commit as synced.
+   */
+  @ParameterizedTest
+  @ValueSource(booleans = {false, true})
+  void testHiveQLSyncFailsWhenHiveRejectsAStatement(boolean batchingEnabled) 
throws Exception {
+    hiveSyncProps.setProperty(HIVE_SYNC_MODE.key(), 
HiveSyncMode.HIVEQL.name());
+    hiveSyncProps.setProperty(HIVE_SYNC_BATCHING_ENABLED.key(), 
String.valueOf(batchingEnabled));
+    hiveSyncProps.setProperty(META_SYNC_PARTITION_FIELDS.key(), 
HoodieRecord.PARTITION_PATH_METADATA_FIELD);
+    HiveTestUtil.createCOWTable("100", 1, true);
+    reInitHiveSyncClient();
+    reSyncHiveTable();
+    assertEquals("100", 
hiveClient.getLastCommitTimeSynced(HiveTestUtil.TABLE_NAME).get());
+
+    hiveSyncProps.setProperty(META_SYNC_PARTITION_FIELDS.key(), "datestr");
+    HiveTestUtil.addCOWPartition("2050/01/01", true, true, "101");
+    reInitHiveSyncClient();
+
+    HoodieException ex = assertThrows(HoodieException.class, 
this::reSyncHiveTable);
+    Throwable rejection = ex;
+    while (rejection != null && !(rejection.getMessage() != null && 
rejection.getMessage().contains("Hive rejected the statement"))) {

Review Comment:
   Great suggestion, simplified, thanks!



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

Reply via email to