You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9fd232a
Browse filesBrowse the repository at this point in the historyBrowse files
fix: choose the AT TIME ZONE branch after type coercion
The SQL planner chose between the naive and the aware lowering from
`Expr::get_type`, which runs before type coercion. So a `CASE` or `UNION`
whose first arm is naive, but whose coerced type is aware, kept the old
aware-in, aware-out result. The same early type also set the `TimeUnit`,
so a first arm with a coarser unit truncated the other arms.
The planner now plans `AT TIME ZONE` as `timezone(zone, expr)` through
`ExprPlanner::plan_at_time_zone`, which now receives the raw operands.
The function decides once the coerced type is known.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# The plan lowers to CAST / to_local_time after simplification. The column is
5982
+
# named with the operator syntax.
5983
+
query TT
5984
+
EXPLAIN SELECT (CASE WHEN b THEN naive ELSE aware END) AT TIME ZONE 'America/Denver', naive AT TIME ZONE 'America/Denver' FROM at_tz_case
5985
+
----
5986
+
logical_plan
5987
+
01)Projection: to_local_time(CAST(CASE WHEN at_tz_case.b THEN CAST(at_tz_case.naive AS Timestamp(ns, "UTC")) ELSE at_tz_case.aware END AS Timestamp(ns, "America/Denver"))) AS CASE WHEN at_tz_case.b THEN at_tz_case.naive ELSE at_tz_case.aware END AT TIME ZONE 'America/Denver', CAST(at_tz_case.naive AS Timestamp(ns, "America/Denver")) AS at_tz_case.naive AT TIME ZONE 'America/Denver'
01)ProjectionExec: expr=[to_local_time(CAST(CASE WHEN b@2 THEN CAST(naive@1 AS Timestamp(ns, "UTC")) ELSE aware@0 END AS Timestamp(ns, "America/Denver"))) as CASE WHEN at_tz_case.b THEN at_tz_case.naive ELSE at_tz_case.aware END AT TIME ZONE 'America/Denver', CAST(naive@1 AS Timestamp(ns, "America/Denver")) as at_tz_case.naive AT TIME ZONE 'America/Denver']
0 commit comments