infvg commented on code in PR #13684:
URL: https://github.com/apache/gluten/pull/13684#discussion_r4628146508
##########
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()
Review Comment:
This only checks top-level columns, can we see if we can either add support
for nested columns, and only if it's not possible without a velox change, raise
the velox PR + verify fallback for nested case.
##########
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 never reaches velox, gluten passes empty serde parameters, and [Velox
sets the timezone to ""
here](https://github.com/IBM/velox/blob/67fa1bbee62e9f8752b3c34cc92f179022cd2ac6/velox/connectors/hive/iceberg/WriterOptionsAdapter.cpp#L54-L55).
##########
backends-velox/src-iceberg/test/scala/org/apache/gluten/execution/enhanced/VeloxIcebergSuite.scala:
##########
@@ -1065,4 +1066,51 @@ class VeloxIcebergSuite extends IcebergSuite {
Seq(Row(1, "hello"), Row(2, "world")))
}
}
+
+ test("GLUTEN-13429: timestamptz columns written with isAdjustedToUTC=true") {
Review Comment:
These tests might not be necessary, please check if this functionality is
tested via our upstream iceberg tests, and if it is, we can remove this.
--
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]