Anirban-Chand opened a new pull request, #13684:
URL: https://github.com/apache/gluten/pull/13684

   ## What changes are proposed in this pull request?
   
   Fixes #13429.
   
   When writing Iceberg tables via the Velox backend, columns with Spark 
`TimestampType` (which map to Iceberg's `timestamptz`) were written into 
Parquet files with `isAdjustedToUTC=false`. 
   
   According to the [Iceberg Table 
Specification](https://iceberg.apache.org/spec/#primitive-types), `timestamptz` 
must be written as Parquet `Timestamp(isAdjustedToUTC=true, unit=micros)`. 
Because the flag was missing/false, strict Iceberg readers such as 
`apache/iceberg-go` fail during operations like table compaction with: `cannot 
promote timestamp to timestamptz`.
   
   ### Root Cause
   1. In Velox (`velox/dwio/parquet/writer/arrow/ArrowSchema.cpp:240`), 
`isAdjustedToUTC` is derived purely from whether the Arrow timestamp type 
carries a non-empty timezone string:
      ```cpp
      const bool utc = !(timestampType.timezone().empty());
      ```
   2. Velox requires the serde parameter `parquet.writer.timestamp.timezone` 
(`ParquetConfig.h:261`) to attach the timezone string during Arrow schema 
construction (`Bridge.cpp:371`).
   3. In `AbstractIcebergWriteExec.scala`, this serde property was not passed 
into `icebergProperties`. As a result, Velox constructed the Arrow schema with 
an empty timezone string (`""`), causing the Parquet footer to default to 
`isAdjustedToUTC=false`.
   
   ### Proposed Fix
   
   In `AbstractIcebergWriteExec.scala`, inspect the Iceberg write schema 
(`writeSchema`). If any column is a `timestamptz` (`col.type().typeId() == 
TypeID.TIMESTAMP && 
col.type().asInstanceOf[Types.TimestampType].shouldAdjustToUTC()`), inject 
`"parquet.writer.timestamp.timezone" -> "UTC"` into `icebergProperties` so 
Velox sets `isAdjustedToUTC=true` in the Parquet footer.
   
   ## How was this patch tested?
   
   - Tested against theoretical type-mapping flow between Gluten and Velox.
   - Marked as Draft while adding a Parquet-footer metadata verification unit 
test in `IcebergSuite` and validating on CI.
   
   ## Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Antigravity


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to