Date type converted to long
I have saved the data of ordered_date But while retrieving I am getting the ordered_date as long type Though the dataset field is of type Date the hudi is treating it as long when ds.write.format is performed
Could you guide in saving the Date by preserving the type
You can not preserve the type without changing the source code. You can check HoodieSparkSqlWriter -> val schema = AvroConversionUtils.convertStructTypeToAvroSchema(df.schema, structName, nameSpace) which used spark-avro package.
Thanks for the reply. So there is no support for saving Date or TimeStamp type in hudi?
PFB the datatype in Dataset before writing to hudi and after reading the data from hudi
Field --- date_last_cr_cust
*******Before saving ******
scala> data_to_be_written.select("date_last_cr_cust").printSchema
root |-- date_last_cr_cust: date (nullable = true)
When the saved data is read from HDFS**
spark.read.format("com.uber.hoodie").load("/apps/hive/warehouse/hoodie_full_account/KI0010200/*")
.select("date_last_cr_cust").
printSchema
root |-- date_last_cr_cust: long (nullable = true)
@sidnakoppa look this https://github.com/uber/hudi/issues/517#issuecomment-448506773
I also found this question. I changed some code in spark-avro and then it transed to LogicalType.
But in Hive 1.2.1, Hive still think it is longType(LogicalType is an ubattribute under base type like long, so Hive recognize it to long). In Hive 1.2.1's lib, Hive use parquet 1.6, date/timestamp/decimal are supported in avro1.8 and parquet1.8.
By the way, In parquet 1.8 or earlier, it doesn't have date type. It just has int96(nanotime type) and stores as bytes.
If you want a long type date, you can use getTime() to save a long, and read by using timestamp function to trans to timestamp type(build like this optional int64 timestamp (TIMESTAMP_MILLIS);).
@sidnakoppa , please follow #547 .. We can follow up there, with all the great analysis @cdmikechen has done already..
Separately, I recommend upgrading to Hive 2.x as much as possible. Speaking from experience at Uber, we had to deal with so many issues on Hive 1.x around schema evolution/data types, since parquet support was pretty raw back then... Is this something that's feasible for you? (all cloud stores for e.g, spin up Hive 2.x by default)
add a comment in https://issues.apache.org/jira/browse/HUDI-91