yihua opened a new issue, #20825: URL: https://github.com/apache/hudi/issues/20825
`SqlKeyGenerator` renders a TIMESTAMP partition value with a Joda `DateTimeFormat` that has no zone, so it uses the JVM default time zone of the task (`SqlKeyGenerator#convertPartitionPathToSqlType` and the `timestampTimeFormat` / `sqlTimestampFormat` formatters; the Row paths also go through `java.sql.Timestamp#toString`, which uses the same zone). Spark renders the partition directories of its own datasource tables in the session time zone (`spark.sql.session.timeZone`), and Hudi parses partition values back from the path in the session time zone too. When the two zones differ, the path holds a shifted value, and the value read back differs from the one written: ```sql -- JVM default zone UTC set spark.sql.session.timeZone=Asia/Tokyo; create table t (id int, v long, ts timestamp) using hudi tblproperties (primaryKey = 'id', orderingFields = 'v') partitioned by (ts); insert into t values (1, 1000, TIMESTAMP '2024-01-01 10:00:00'); -- path: ts=2024-01-01 01%3A00%3A00 select cast(ts as string) from t; -- 2024-01-01 01:00:00 select id from t where ts = TIMESTAMP '2024-01-01 10:00:00'; -- no rows ``` A Spark parquet table with the same statements writes `ts=2024-01-01 10%3A00%3A00` and returns the row. COW and MOR behave the same, as does `hoodie.datasource.read.extract.partition.values.from.path=true`. The written path also depends on the executors' JVM zone, so two writers with the same session zone can disagree. Rendering in the session zone would move new writes of an existing value to a different directory on any table written so far with a session zone other than the JVM zone, splitting a key across two partition paths. So the rendering has to be fixed per table: record a table config when a partitioned table is created, under which `SqlKeyGenerator` renders in the session zone passed through the write config, and keep the current rendering for tables without it. #20817 proposes a table config of the same kind for the fractional seconds of the same paths, recorded in the same places; the two belong in one recorded layout, so this is best built on top of that change. -- 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]
