codope commented on code in PR #6731:
URL: https://github.com/apache/hudi/pull/6731#discussion_r981331940


##########
hudi-cli/src/main/java/org/apache/hudi/cli/commands/SparkMain.java:
##########
@@ -473,21 +482,24 @@ private static void deleteOlderPartition(String basePath, 
String oldPartition, D
   }
 
   private static void rewriteRecordsToNewPartition(String basePath, String 
newPartition, Dataset<Row> recordsToRewrite, HoodieTableMetaClient metaClient, 
Map<String, String> propsMap) {
-    
recordsToRewrite.withColumn(metaClient.getTableConfig().getPartitionFieldProp(),
 functions.lit(newPartition))
+    String partitionFieldProp = 
metaClient.getTableConfig().getPartitionFieldProp();
+    StructType structType = recordsToRewrite.schema();
+    int partitionIndex = structType.fieldIndex(partitionFieldProp);
+
+    
recordsToRewrite.withColumn(metaClient.getTableConfig().getPartitionFieldProp(),
 functions.lit(null).cast(structType.apply(partitionIndex).dataType()))
         .write()
         .options(propsMap)
-        .option("hoodie.datasource.write.operation", "insert")
+        .option("hoodie.datasource.write.operation", 
WriteOperationType.BULK_INSERT.value())
         .format("hudi")
         .mode("Append")
         .save(basePath);
   }
 
   private static Dataset<Row> getRecordsToRewrite(String basePath, String 
oldPartition, SQLContext sqlContext) {
     return sqlContext.read()
-        .option("hoodie.datasource.read.extract.partition.values.from.path", 
"false")
+        //.option("hoodie.datasource.read.extract.partition.values.from.path", 
"false")

Review Comment:
   i've removed it.



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