infvg commented on code in PR #13684:
URL: https://github.com/apache/gluten/pull/13684#discussion_r4663993062


##########
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:
   This still never reaches velox, [gluten passes empty serdeParameters to the 
insert 
handle](https://github.com/apache/gluten/blob/4109c98717b08faffca439bb227d0283816eefae/cpp/velox/compute/iceberg/IcebergWriter.cc#L161-L169).
 



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