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


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala:
##########
@@ -530,6 +539,40 @@ object ProvidesHoodieConfig {
       filterNullValues(overridingOpts)
   }
 
+  /**
+   * @param tableConfigKeyGeneratorClassName     key generator class name in 
the table config.
+   * @param partitionFieldNamesWithoutKeyGenType partition field names without 
key generator types
+   *                                             from the table config.
+   * @param catalogTable                         HoodieCatalogTable instance 
to fetch table properties.
+   * @return the write config value to set for 
"hoodie.datasource.write.partitionpath.field".
+   */
+  def getPartitionPathFieldWriteConfig(tableConfigKeyGeneratorClassName: 
String,
+                                       partitionFieldNamesWithoutKeyGenType: 
String,
+                                       catalogTable: HoodieCatalogTable): 
String = {
+    if (StringUtils.isNullOrEmpty(tableConfigKeyGeneratorClassName)) {
+      partitionFieldNamesWithoutKeyGenType
+    } else {
+      val writeConfigPartitionField = 
catalogTable.catalogProperties.get(PARTITIONPATH_FIELD.key())

Review Comment:
   As an example, the table looks like this in Spark catalog:
   ```
   spark-sql (default)> DESCRIBE TABLE formatted h0;
   24/04/12 13:59:53 WARN ObjectStore: Failed to get database global_temp, 
returning NoSuchObjectException
   _hoodie_commit_time  string                                      
   _hoodie_commit_seqno string                                      
   _hoodie_record_key   string                                      
   _hoodie_partition_path       string                                      
   _hoodie_file_name    string                                      
   id                   int                                         
   name                 string                                      
   price                decimal(5,1)                                
   ts                   int                                         
   segment              string                                      
   # Partition Information                                                  
   # col_name           data_type               comment             
   ts                   int                                         
   segment              string                                      
                                                                    
   # Detailed Table Information                                             
   Catalog              spark_catalog                               
   Database             default                                     
   Table                h0                                          
   Owner                ethan                                       
   Created Time         Fri Apr 12 13:58:05 PDT 2024                        
   Last Access          UNKNOWN                                     
   Created By           Spark 3.5.1                                 
   Type                 EXTERNAL                                    
   Provider             hudi                                        
   Table Properties     
[hoodie.datasource.write.partitionpath.field=ts:timestamp,segment:simple, 
preCombineField=name, primaryKey=id, provider=hudi, type=cow]                   
  
   Location             
file:/private/var/folders/60/wk8qzx310fd32b2dp7mhzvdc0000gn/T/spark-4ac6fb47-e20b-4679-a668-e28238ec3e05/h0
                         
   Serde Library        
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe                     
    
   InputFormat          org.apache.hudi.hadoop.HoodieParquetInputFormat         
            
   OutputFormat         
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat                  
    
   Time taken: 1.694 seconds, Fetched 30 row(s)
   ```



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