fix: use UTC for Arrow schema timezone in SparkToColumnar conversions#3878
Open
andygrove wants to merge 1 commit intoapache:mainfrom
Open
fix: use UTC for Arrow schema timezone in SparkToColumnar conversions#3878andygrove wants to merge 1 commit intoapache:mainfrom
andygrove wants to merge 1 commit intoapache:mainfrom
Conversation
…d CometLocalTableScanExec
CometSparkToColumnarExec and CometLocalTableScanExec used the session
timezone for Arrow schema metadata, but the native side always
deserializes Timestamp as Timestamp(Microsecond, Some("UTC")). This
causes an unnecessary cast in ScanExec when timezones don't match.
Spark's internal timestamps are always UTC microseconds, so the
timezone in the Arrow schema is purely metadata. Using UTC matches
NativeBatchReader and the native serde.
Also remove outdated "known issues with non-UTC timezones" warnings
from config descriptions and move configs from testing to exec category.
Closes apache#2720
parthchandra
reviewed
Apr 3, 2026
| } | ||
| } | ||
|
|
||
| test("LocalTableScanExec with timestamps in non-UTC timezone") { |
Contributor
There was a problem hiding this comment.
Do we need COMET_SPARK_TO_ARROW_ENABLED to be set to true for these tests?
| @@ -222,31 +222,28 @@ object CometConf extends ShimCometConf { | |||
|
|
|||
| val COMET_CONVERT_FROM_PARQUET_ENABLED: ConfigEntry[Boolean] = | |||
Contributor
There was a problem hiding this comment.
Are there any test which exercise COMET_CONVERT_FROM_PARQUET_ENABLED, COMET_CONVERT_FROM_JSON_ENABLED, and COMET_CONVERT_FROM_CSV_ENABLED, since these will no longer be 'experimental' ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #2720
Closes #2733
Rationale for this change
CometSparkToColumnarExecandCometLocalTableScanExecusedconf.sessionLocalTimeZonewhen creating Arrow schemas for timestamp columns. However, the native side always deserializesTimestampasTimestamp(Microsecond, Some("UTC"))inserde.rs. When the session timezone is non-UTC, this causes a timezone mismatch between the Arrow data schema and the native plan schema.The native
ScanExec.make_record_batchdetects this mismatch and casts the column to match. Since Arrow timestamps with timezone are always stored as UTC microseconds internally, this cast is a no-op on the data — but it adds unnecessary overhead and is inconsistent withNativeBatchReader(the Parquet scan path), which already hardcodes UTC.What changes are included in this PR?
CometSparkToColumnarExecandCometLocalTableScanExecto use"UTC"instead ofconf.sessionLocalTimeZonefor Arrow schema timezone, matchingNativeBatchReaderand nativeserde.rsspark.comet.convert.parquet.enabled,spark.comet.convert.json.enabled,spark.comet.convert.csv.enabled, andspark.comet.sparkToColumnar.enabledtestingtoexeccategory since the timezone concern is resolvedHow are these changes tested?
Added two tests in
CometExecSuite:LocalTableScanExec with timestamps in non-UTC timezone— verifies correct results withCometLocalTableScanExecwhen session timezone isAmerica/Los_Angelessort on timestamps with non-UTC timezone via LocalTableScan— verifies correct results through a sort + repartition path with non-UTC timezoneAll 90 tests in
CometExecSuitepass.