yihua commented on code in PR #13677:
URL: https://github.com/apache/hudi/pull/13677#discussion_r2268274211


##########
hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngrade.java:
##########
@@ -347,6 +355,60 @@ public void 
testMetadataTableUpgradeDowngradeFailure(HoodieTableVersion fromVers
         "Exception message should contain metadata table failure message");
   }
 
+  @ParameterizedTest
+  @CsvSource({"1","2","3","4","5","6","7","8","9","null"})
+  void testTableVersionDuringTableCreation(String targetTableVersion) {
+    SparkSession spark = spark();
+    Map<String, String> writeOptions = new HashMap<>();
+    if (!targetTableVersion.equals("null")) {
+      writeOptions.put(HoodieWriteConfig.WRITE_TABLE_VERSION.key(), 
targetTableVersion);
+    }
+    writeOptions.put(HoodieWriteConfig.TBL_NAME.key(), "testTableCreation");
+    HoodieTestDataGenerator dataGen = new HoodieTestDataGenerator();
+    List<String> records = recordsToStrings(dataGen.generateInserts("001", 5));
+    Dataset<Row> inputDF = spark.read().json(jsc().parallelize(records, 2));
+
+    // Create table, and validate.
+    Set<String> failSet = new HashSet<>(Arrays.asList("1", "2", "3", "4", 
"5"));
+    if (failSet.contains(targetTableVersion)) {
+      // This fails at HoodieTableMetaClient.
+      assertThrows(HoodieNotSupportedException.class, () -> {
+        inputDF.write().format("org.apache.hudi")
+            .partitionBy("partition")
+            .options(writeOptions)
+            .mode(SaveMode.Append)
+            .save(basePath());
+      });
+    } else if (targetTableVersion.equals("7")) {
+      // Fails at write table version check.
+      assertThrows(IllegalArgumentException.class, () -> {
+        inputDF.write().format("org.apache.hudi")

Review Comment:
   Fixed



##########
hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/table/upgrade/TestUpgradeDowngrade.java:
##########
@@ -347,6 +355,60 @@ public void 
testMetadataTableUpgradeDowngradeFailure(HoodieTableVersion fromVers
         "Exception message should contain metadata table failure message");
   }
 
+  @ParameterizedTest
+  @CsvSource({"1","2","3","4","5","6","7","8","9","null"})
+  void testTableVersionDuringTableCreation(String targetTableVersion) {
+    SparkSession spark = spark();
+    Map<String, String> writeOptions = new HashMap<>();
+    if (!targetTableVersion.equals("null")) {
+      writeOptions.put(HoodieWriteConfig.WRITE_TABLE_VERSION.key(), 
targetTableVersion);
+    }
+    writeOptions.put(HoodieWriteConfig.TBL_NAME.key(), "testTableCreation");
+    HoodieTestDataGenerator dataGen = new HoodieTestDataGenerator();
+    List<String> records = recordsToStrings(dataGen.generateInserts("001", 5));
+    Dataset<Row> inputDF = spark.read().json(jsc().parallelize(records, 2));
+
+    // Create table, and validate.
+    Set<String> failSet = new HashSet<>(Arrays.asList("1", "2", "3", "4", 
"5"));
+    if (failSet.contains(targetTableVersion)) {
+      // This fails at HoodieTableMetaClient.
+      assertThrows(HoodieNotSupportedException.class, () -> {
+        inputDF.write().format("org.apache.hudi")
+            .partitionBy("partition")
+            .options(writeOptions)
+            .mode(SaveMode.Append)
+            .save(basePath());
+      });
+    } else if (targetTableVersion.equals("7")) {

Review Comment:
   Fixed



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