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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/HoodieTableMetaClient.java:
##########
@@ -1473,10 +1474,7 @@ public Properties build() {
       tableConfig.setValue(HoodieTableConfig.NAME, tableName);
       tableConfig.setValue(HoodieTableConfig.TYPE, tableType.name());
 
-      if (null == tableVersion) {
-        tableVersion = HoodieTableVersion.current();
-      }
-
+      tableVersion = getTableVersionProperly();

Review Comment:
   Addressed



##########
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")

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