Keep the time zone of TIMESTAMP results (non-UTC session time zones) - #79
Open
aminghadersohi wants to merge 1 commit into
Open
aminghadersohi wants to merge 1 commit into
aminghadersohi wants to merge 1 commit into
Conversation
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.
aminghadersohi
requested review from
deeksha-db,
gopalldb,
jackyhu-db,
jayantsing-db,
jprakash-db,
samikshya-db,
shivam2680 and
vikrantpuppala
as code owners
September 26, 2026 09:53
This branch has not been deployed
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.
What type of PR is this?
Description
Problem
TIMESTAMPwrapssqlalchemy.DateTime. The dialect'scolspecsadapt that impl toTIMESTAMP_NTZ, whoseprocess_result_valuestripstzinfo;TIMESTAMP.process_result_valuethen 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 as2024-02-29T23:59:58-07:00(stored correctly,2024-03-01 12:29:58IST) is read back through aTIMESTAMPcolumn as2024-03-01T12:29:58+00:00, 5h30 off. The raw connector cursor returns the correct+05:30value.Change
TIMESTAMP.result_processoruses onlyTIMESTAMP.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?
test_timestamp_result_keeps_session_time_zonefails onmainand passes here;test_parsing.py,test_types.py,test_ddl.pypass.Related Tickets & Documents
None.