Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'AT TIME ZONE' issue near DST change time with DATETIME2 datatype conversion #3346

Conversation

Anikait143
Copy link
Contributor

Description

1. Issues

  • Convert function when converting to datetime2, datetime, smalldatettime with given timezone using AT TIME ZONE gives wrong output near DST change time.

2. Changes made to fix the issues

  • Fix timestamp value to consider it in the given timezone instead of UTC for datetime2, datetime, smalldatettime datatypes. This fixes the issue and also makes it independent of local timezone setting.
# Input
1> SELECT CONVERT(DATETIME2(0), '2022-03-27T02:00:00', 126) AT TIME ZONE 'Central European Standard Time';
2> GO
# previous output (wrong output)               

---------------------------------------------
          2022-03-27 02:00:00.0000000 +02:00
# current output (correct output)

---------------------------------------------
          2022-03-27 03:00:00.0000000 +02:00                                                                                                                                                                                                                                           
# previous output (wrong output)
1> SELECT CONVERT(DATETIME2(0), '2022-03-27T01:01:00') AT TIME ZONE 'Central European Standard Time';
2> GO
timezone 
---------------------------------------------
           2022-03-27 01:01:00.0000000 +02:00

(1 rows affected)
# current output (correct output)
1> SELECT CONVERT(DATETIME2(0), '2022-03-27T01:01:00') AT TIME ZONE 'Central European Standard Time';
2> GO
timezone 
---------------------------------------------
           2022-03-27 01:01:00.0000000 +01:00

(1 rows affected)
  • Added Test Cases for this issue

cherry-picked: #3343
Task: BABEL-5513
Authored-by: Anikait Agrawal [email protected]
Signed-off-by: Anikait Agrawal [email protected]

Test Scenarios Covered

  • Use case based - YES

  • Boundary conditions - YES

  • Arbitrary inputs -

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Memory tests -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 12593663257

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.001%) to 74.879%

Files with Coverage Reduction New Missed Lines %
contrib/babelfishpg_tds/src/backend/tds/tdsutils.c 1 73.66%
Totals Coverage Status
Change from base Build 12584870045: 0.001%
Covered Lines: 46736
Relevant Lines: 62415

💛 - Coveralls

@shardgupta shardgupta merged commit 928987e into babelfish-for-postgresql:BABEL_4_X_DEV Jan 3, 2025
47 checks passed
@shardgupta shardgupta deleted the babel-5513-4x branch January 3, 2025 11:12
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.

4 participants