vinishjail97 commented on code in PR #806:
URL: https://github.com/apache/incubator-xtable/pull/806#discussion_r2839192552


##########
xtable-core/src/test/java/org/apache/xtable/parquet/ITParquetConversionSource.java:
##########
@@ -153,7 +152,7 @@ private static ConversionConfig getTableSyncConfig(
                         .name(tableName)
                         .formatName(formatName)
                         // set the metadata path to the data path as the 
default (required by Hudi)
-                        .basePath(table.getDataPath())
+                        .basePath(table.getBasePath())

Review Comment:
   Nit: the comment on line 154 still says "set the metadata path to the 
**data** path" but the code now uses `getBasePath()`. Update the comment to 
match.



##########
xtable-core/src/test/java/org/apache/xtable/parquet/ITParquetConversionSource.java:
##########
@@ -319,43 +268,62 @@ public void 
testFilePartitionedData(TableFormatPartitionDataHolder tableFormatPa
                   new Timestamp(System.currentTimeMillis() + 1500)));
 
       Dataset<Row> dfAppend = sparkSession.createDataFrame(dataToAppend, 
schema);
-      dfAppend
-          .withColumn(
-              "year", 
functions.year(functions.col("timestamp").cast(DataTypes.TimestampType)))
-          .withColumn(
-              "month",
-              
functions.date_format(functions.col("timestamp").cast(DataTypes.TimestampType), 
"MM"))
-          .write()
-          .mode(SaveMode.Append)
-          .partitionBy("year", "month")
-          .parquet(dataPathPart);
-      GenericTable tableAppend;
-      tableAppend =
-          GenericTable.getInstance(
-              tableName, Paths.get(dataPathPart), sparkSession, jsc, 
sourceTableFormat, true);
-      try (GenericTable tableToCloseAppended = tableAppend) {
-        ConversionConfig conversionConfigAppended =
-            getTableSyncConfig(
-                sourceTableFormat,
-                SyncMode.FULL,
-                tableName,
-                tableAppend,
-                targetTableFormats,
-                xTablePartitionConfig,
-                null);
-        ConversionController conversionControllerAppended =
-            new ConversionController(jsc.hadoopConfiguration());
-        conversionControllerAppended.sync(conversionConfigAppended, 
conversionSourceProvider);
+      writeData(dfAppend, dataPath, xTablePartitionConfig);
+      ConversionConfig conversionConfigAppended =
+          getTableSyncConfig(
+              sourceTableFormat,
+              tableFormatPartitionDataHolder.getSyncMode(),
+              tableName,
+              table,
+              targetTableFormats,
+              xTablePartitionConfig,
+              null);
+      ConversionController conversionControllerAppended =
+          new ConversionController(jsc.hadoopConfiguration());
+      conversionControllerAppended.sync(conversionConfigAppended, 
conversionSourceProvider);
+      checkDatasetEquivalenceWithFilter(
+          sourceTableFormat, table, targetTableFormats, isPartitioned);
+    }
+  }
+
+  private void writeData(Dataset<Row> df, String dataPath, String 
partitionConfig) {
+    if (partitionConfig != null) {
+      // extract partition columns from config
+      String[] partitionCols =
+          Arrays.stream(partitionConfig.split(":")[2].split("/"))
+              .map(s -> s.split("=")[0])
+              .toArray(String[]::new);
+      // add partition columns to dataframe
+      for (String partitionCol : partitionCols) {
+        if (partitionCol.equals("year")) {

Review Comment:
   The `if/else if` chain only handles "year", "month", and "day". If the 
partition config ever contains a different column, no column gets added to the 
DataFrame but `partitionBy` still references it — causing a confusing 
`AnalysisException`. Add an `else` with `throw new 
IllegalArgumentException("Unsupported partition column: " + partitionCol)` to 
fail fast.



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