Anirban-Chand commented on code in PR #13684:
URL: https://github.com/apache/gluten/pull/13684#discussion_r4628521750
##########
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:
Good catch, thanks @infvg! You're right—Velox's `WriterOptionsAdapter.cpp`
explicitly overrides `kWriterSerdeTimestampTimezone = ""` in `applyPreConfigs`,
which causes `ArrowSchema.cpp:240` to write `isAdjustedToUTC=false`.
A proper fix will require updating Velox's `WriterOptionsAdapter.cpp` to set
`"UTC"` for `timestamptz`. I'll open a PR in Velox for this.
##########
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:
Agreed. I'll update the check using `TypeUtil.visit(...)` to cover nested
fields recursively. I will also verify fallback behavior if Velox can't support
mixed/nested types without deeper changes.
--
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]