Skip to content

Keep the time zone of TIMESTAMP results (non-UTC session time zones) - #79

Open
aminghadersohi wants to merge 1 commit into
databricks:mainfrom
aminghadersohi:fix-timestamp-result-timezone
Open

aminghadersohi wants to merge 1 commit into
databricks:mainfrom
aminghadersohi:fix-timestamp-result-timezone

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Sep 26, 2026 •

Copy link
Copy Markdown

What type of PR is this?

  • Bug Fix

Description

Problem

TIMESTAMP wraps sqlalchemy.DateTime. The dialect's colspecs adapt that impl to TIMESTAMP_NTZ, whose process_result_value strips tzinfo; TIMESTAMP.process_result_value then sees a naive value and labels it UTC.

The connector returns an aware datetime in the session time zone, so whenever the session time zone is not UTC the instant is wrong. Observed on a SQL warehouse with session_configuration={"TIMEZONE": "Asia/Kolkata"}: a row written as 2024-02-29T23:59:58-07:00 (stored correctly, 2024-03-01 12:29:58 IST) is read back through a TIMESTAMP column as 2024-03-01T12:29:58+00:00, 5h30 off. The raw connector cursor returns the correct +05:30 value.

Change

TIMESTAMP.result_processor uses only TIMESTAMP.process_result_value (aware values kept, naive values labelled UTC as before), so the NTZ processor no longer runs on TIMESTAMP results.

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually
  • N/A

test_timestamp_result_keeps_session_time_zone fails on main and passes here; test_parsing.py, test_types.py, test_ddl.py pass.

Related Tickets & Documents

None.

TIMESTAMP wraps DateTime, which the dialect's colspecs adapt to
TIMESTAMP_NTZ; its result processing drops tzinfo, and TIMESTAMP then
labelled the session-local wall clock as UTC. With a non-UTC session
time zone every value read through a TIMESTAMP column was shifted
(e.g. 06:59:58Z read back as 12:29:58+00:00 under Asia/Kolkata).
Use TIMESTAMP's own result processing only.

This branch has not been deployed

No deployments
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