Skip to content

feat: opt timezone expressions into codegen dispatch#4638

Open
andygrove wants to merge 2 commits into
apache:mainfrom
andygrove:feat/codegen-dispatch-timezone
Open

feat: opt timezone expressions into codegen dispatch#4638
andygrove wants to merge 2 commits into
apache:mainfrom
andygrove:feat/codegen-dispatch-timezone

Conversation

@andygrove

Copy link
Copy Markdown
Member

Which issue does this PR close?

Part of #4596 (the timezone group: from_utc_timestamp, to_utc_timestamp, convert_timezone).

Rationale for this change

All three report Incompatible for the same reason: Comet's native timezone parser does not accept Spark's legacy zone forms (PST, GMT+1, UTC+1, ...), so those throw a native parse error (#2013). With allowIncompatible unset the whole projection falls back to Spark. They have a real Spark doGenCode and supported input/output types, so they are eligible for the CodegenDispatchFallback path: route the Incompatible result through the JVM codegen dispatcher (Spark's own doGenCode inside the Comet pipeline) so the projection stays native, matches Spark exactly, and handles every timezone form.

What changes are included in this PR?

  • CometFromUTCTimestamp, CometToUTCTimestamp, CometConvertTimezone mix in CodegenDispatchFallback. The native incompatible path stays opt-in via allowIncompatible.
  • docs/source/user-guide/latest/expressions.md notes updated: these route through the dispatcher by default and now handle all timezone forms.

How are these changes tested?

New from_utc_timestamp_dispatch.sql, to_utc_timestamp_dispatch.sql, and convert_timezone_dispatch.sql, each with allowIncompatible unset and a ConfigMatrix: spark.sql.session.timeZone=UTC,America/Los_Angeles. They assert native execution matching Spark across both session zones (confirming the resolved timeZoneId survives closure serialization, the concern called out in the issue), and include the legacy PST / GMT+1 forms the native path rejects but the dispatcher handles. The existing allowIncompatible=true native-path tests still pass. All run with CometSqlFileTestSuite on Spark 3.5.

… codegen dispatch

Mixes CodegenDispatchFallback into the three timezone serdes so their Incompatible
result (the native parser rejects legacy zone forms like PST / GMT+1, apache#2013) routes
through the JVM codegen dispatcher and matches Spark exactly, including those forms,
instead of falling back. The native path stays opt-in via allowIncompatible.

Part of apache#4596.
@andygrove andygrove added this to the 0.17.0 milestone Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant