Repository navigation
Make the session-timezone comparison rule public, and deprecate the two helpers it orphans - #3
Closed
adriangb wants to merge 5 commits into
Conversation
`0390171` added a private `comparison_coercion_with_session_timezone` to the analyzer so `IN`, `BETWEEN` and `CASE expr WHEN` coerce the way `=` does. That is the right rule, but it is the only copy of it and it is not reachable from outside `datafusion-optimizer`. Move it to `expr-common`, next to `comparison_coercion` itself, and make it `pub`. Nothing changes for the analyzer, which keeps calling it in the same three places; it just no longer owns the rule. Also documents *why* `timestamp_types_with_session_timezone` exists, and covers the new function with a unit test — including the `None` session timezone and the `Null`-versus-dictionary case, where routing through `=` differs from `comparison_coercion`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both are thin folds of `comparison_coercion`, and both are now unreachable from
the planner: `0390171` coerces `IN` and `CASE expr WHEN` through `=` so they
pick up the `datafusion.execution.time_zone` rule, and these two functions have
nowhere to take that setting from.
Leaving them as they are would leave two `pub` functions that still answer the
question "how does `IN` coerce?" with an answer DataFusion itself no longer
uses. Adding a `session_time_zone` parameter would answer it correctly, but
that is a breaking change to a signature with known downstream callers, for a
reason the API health policy lists as weak ("an internal refactor to make
DataFusion more consistent").
So deprecate them in 56.0.0 instead, pointing at
`comparison_coercion_with_session_timezone`. Nothing breaks today, callers get
a compiler warning and a worked example of the replacement fold, and the
decision stays reversible for the six versions before removal.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
adriangb
force-pushed
the
claude/datafusion-pr-25094-merge-weal0o
branch
from
September 10, 2026 17:32
4493734 to
2fbac69
Compare
IN, BETWEEN and CASE WHEN through the same rule as =
kumarUjjawal
force-pushed
the
fix/13212-timezone-inference
branch
from
September 11, 2026 05:50
d49d3d1 to
8208a55
Compare
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?
Nothing on its own — this targets your
fix/13212-timezone-inferencebranch, i.e. it is afollow-up to apache#25094. Merging it updates that PR.
Rationale for this change
0390171reachesINandCASE expr WHENby inlining the folds that used to live inget_coerce_type_for_listandget_coerce_type_for_case_when. That leaves two things behind:INcoerces the way=does, session timezone included" — exists onlyas a private function inside
datafusion-optimizer.pubhelpers still answer the question "how doesINcoerce?", with an answerDataFusion itself no longer uses.
Those helpers aren't dead code. A GitHub search turns up two non-fork callers of
get_coerce_type_for_list: Canner/WrenAI, which vendors a copy of this very rewriter,and waynexia/jsonfusion, which uses it for its own
IN-list inference.get_coerce_type_for_case_whenhas no external callers I can find.An earlier version of this PR gave both helpers a
session_time_zoneparameter instead. Thatis a breaking change —
api-health.mdlists "adding new required parameters" firstamong breaking changes, and lists "an internal refactor to make DataFusion more consistent"
among the weak reasons to make one. It also wouldn't have helped those two callers: they'd
pass
Noneand land exactly where they started. Deprecation is non-breaking, gives them awarning plus a documented replacement, and stays reversible.
What changes are included in this PR?
Two commits:
Give the session-timezone comparison rule one public home. Moves
comparison_coercion_with_session_timezoneout of the analyzer and intoexpr-common,next to
comparison_coercionitself, aspub. The analyzer calls it in the same threeplaces; it just no longer owns the rule. Adds a unit test covering the
Nonesessiontimezone and the
Null-versus-dictionary case, where routing through=differs fromcomparison_coercion.Deprecate
get_coerce_type_for_listandget_coerce_type_for_case_when(
since = "56.0.0"), pointing at that function, with a worked example of the replacementfold in the rustdoc and an entry in the 56.0.0 upgrade guide.
The analyzer's coercion behavior is unchanged by both commits — this is API shape only.
Are there any user-facing changes?
No breaking changes. One new public function, two deprecations, and an upgrade-guide entry.
Per the API health policy the deprecated functions stay for six major versions, so nothing
has to move before 62.0.0.
Verified locally:
cargo fmt --all -- --check;cargo clippy --all-targets -D warningsandthe unit tests for
datafusion-expr-common,datafusion-expranddatafusion-optimizer;cargo test -p datafusion-expr --doc; and 76 sqllogictest files includingdatetime/timestamps.slt.🤖 Generated with Claude Code