ad1happy2go commented on issue #10110:
URL: https://github.com/apache/hudi/issues/10110#issuecomment-1814968575

   @soumilshah1995 There is a bit of issue with your query I guess. I tried 
below code for which the parsing works. Although facing some other problem. `No 
plan for CreateIndex 
hudi_func_index_01a19d91_699f_4ead_afe1_82a232f91efa_datestr, column_stats, 
false,` Can you try once. 
   
   ```
   # Sample data
   data = [
       [1695159649, '334e26e9-8355-45cc-97c6-c31daf0df330', 'rider-A', 
'driver-K', 19.10, 'san_francisco'],
       [1695159649, 'e96c4396-3fad-413a-a942-4cb36106d721', 'rider-C', 
'driver-M', 27.70, 'san_francisco'],
   ]
   
   # Define schema for the DataFrame
   schema = StructType([
       StructField("ts", LongType(), True),
       StructField("transaction_id", StringType(), True),
       StructField("rider", StringType(), True),
       StructField("driver", StringType(), True),
       StructField("price", FloatType(), True),
       StructField("location", StringType(), True),
   ])
   
   # Create Spark DataFrame
   df = spark.createDataFrame(data, schema=schema)
   
   df.show()
   
   
   hudi_options = {
       'hoodie.table.name': TABLE_NAME,
       'hoodie.datasource.write.operation': 'upsert',
       'hoodie.datasource.write.recordkey.field': 'transaction_id',
       'hoodie.datasource.write.precombine.field': 'ts',
       'hoodie.datasource.write.partitionpath.field': 'location',
       'hoodie.parquet.small.file.limit':'0'
   }
   
   df.write.format("hudi").options(**hudi_options).mode("append").save(PATH)
   
   spark.read.format("hudi").load(PATH).createOrReplaceTempView(TABLE_NAME)
   
   spark.sql(f"""SELECT from_unixtime(ts, 'yyyy-MM-dd') as datestr FROM 
{TABLE_NAME}""").show()
   spark.sql(f"""CREATE INDEX {TABLE_NAME}_datestr ON {TABLE_NAME} USING 
column_stats(ts) options(func='from_unixtime', format='yyyy-MM-dd')""")
   ```


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