You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/02/09 09:36:58 UTC

[GitHub] [hudi] wjcwin edited a comment on issue #4678: [SUPPORT] spark.read.format("hudi").schema(userSpecifiedSchema) doesn't work in version 0.10.0 ,but does work in 0.5.3

wjcwin edited a comment on issue #4678:
URL: https://github.com/apache/hudi/issues/4678#issuecomment-1033556404


   > @wjcwin can you give some details like codes and your expected result. that will help us to locate this issue.
   
   ```
     def getHudi(spark: SparkSession, path: String, dataSchema: StructType): DataFrame = {
       val df: DataFrame =
         spark.read.format("hudi")
           .schema(dataSchema)
           .load(path + "/*")
       df
     }
   
     def getHudi(spark: SparkSession, path: String): DataFrame = {
       var df: DataFrame =
         spark.read.format("org.apache.hudi")
           .load(path + "/*")
           .select("pay_time")
       val swithcSchema = switchSchema(df)
       df = getHudi(spark, path, swithcSchema)
       df
     }
   
     def switchSchema(df: DataFrame): StructType = {
       val orgSchema = df.schema
       orgSchema.printTreeString()
       val swithcSchema = StructType(orgSchema.map(f =>
         if (f.dataType == DataTypes.TimestampType) {
           StructField(f.name, DataTypes.LongType)
         } else {
           f
         }
       ))
       swithcSchema.printTreeString()
       swithcSchema
     }
   ```
   i just want to convert DataTypes.TimestampType to DataTypes.LongType ,  when i use hudi.version 0.5.3 ,i got expect
   but when i use hudi.version 0.10.0 , result is not expect
   
   


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org