Anirban-Chand commented on code in PR #13684:
URL: https://github.com/apache/gluten/pull/13684#discussion_r4704839430
##########
backends-velox/src-iceberg/main/scala/org/apache/gluten/execution/AbstractIcebergWriteExec.scala:
##########
@@ -58,6 +59,30 @@ abstract class AbstractIcebergWriteExec extends
IcebergWriteExec {
val icebergProperties = new util.HashMap[String, String]
+ // Fix for https://github.com/apache/gluten/issues/13429
+ // Spark's TimestampType maps to Iceberg's `timestamptz`
(shouldAdjustToUTC = true).
+ // Velox's Parquet writer derives isAdjustedToUTC from whether the Arrow
timestamp type
+ // carries a non-empty timezone string (ArrowSchema.cpp:240). Without the
serde property
+ // below, the Arrow schema is built with an empty timezone →
isAdjustedToUTC=false in
+ // the Parquet footer, violating the Iceberg spec and breaking strict
readers such as
+ // apache/iceberg-go during compaction ("cannot promote timestamp to
timestamptz").
+ //
+ // Limitation: this sets a file-level timezone flag. Tables containing
both `timestamptz`
+ // and `timestamp_ntz` columns are not currently supported by the native
Iceberg write
+ // path (validation in IcebergWriteExec blocks them). If per-column
support is needed in
+ // future, consider Option 2/3 discussed in
https://github.com/apache/gluten/issues/13429.
+ val hasTimestampTz = writeSchema
+ .columns()
+ .asScala
+ .exists {
+ col =>
+ col.`type`().typeId() == TypeID.TIMESTAMP &&
+ col.`type`().asInstanceOf[Types.TimestampType].shouldAdjustToUTC()
+ }
+ if (hasTimestampTz) {
+ icebergProperties.put("parquet.writer.timestamp.timezone", "UTC")
Review Comment:
Fixed in `cpp/velox/compute/iceberg/IcebergWriter.cc` —
`createSerdeParameters` now extracts
`parquet::ParquetConfig::kWriterSerdeTimestampTimezone` from `sparkConfs` and
forwards it into `IcebergInsertTableHandle::serdeParameters`. Upstream
facebookincubator/velox#20487 (`9c6c9667b2c`) is also merged to preserve
caller-provided timezone in `ParquetWriterOptionsAdapter`.
--
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]