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 issue with convert function when converting string to date, datetimeoffset, datetime2, datetime, smalldatetime or time #3336

Merged

Conversation

rohit01010
Copy link
Contributor

@rohit01010 rohit01010 commented Jan 1, 2025

Description

This PR will add fix for following issues:

  • For converting string to datetime2, datetimeoffset and smalldatetime using convert function, we are directly using cast function which will convert the string to given type with default style. Added support to use corresponding SQL helper functions defined which will fix this issue.
  • For conversion of string to date, datetime, smalldatetime and time using convert function, there are helper functions defined but are unable to handle all the supported datetime string literals. Refactored these definitions and fixed this issue.
  • For conversion of string to datetime2 and datetimeoffset using convert function, there are no helper functions defined which handles this conversion as there are for conversion of string to date, datetime, smalldatetime and time. Added definitions to handle these datatypes as well.
  • Function sys.babelfish_get_microsecs_from_fractsecs() is unable to handle the edge case where fractional seconds get overflowed after rounding it to given scale.
  • Function babelfish_get_timeunit_from_string only returns HOURS, MINUTES, SECONDS and FRACTSECONDS from a given time string. Extended this function to return OFFHOURS, OFFMINUTES and OFFSIGN to get details of timeoffset from time string.

Cherry-picked from: #2622, #2653

Authored-by: Rohit Bhagat [email protected]
Signed-off-by: Rohit Bhagat [email protected]

Issues Resolved

BABEL-4896

Test Scenarios Covered

  • Use case based - YES

  • Boundary conditions - YES

  • Arbitrary inputs - YES

  • Negative test cases - YES

  • Minor version upgrade tests - YES

  • Major version upgrade tests - YES

  • Performance tests - NA

  • Tooling impact - NA

  • Client tests - YES

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.

Rohit Bhagat added 5 commits January 1, 2025 04:29
…imeoffset, datetime2, datetime, smalldatetime or time

Signed-off-by: Rohit Bhagat <[email protected]>
Signed-off-by: Rohit Bhagat <[email protected]>
Signed-off-by: Rohit Bhagat <[email protected]>
Copy link
Contributor

@Anikait143 Anikait143 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shardgupta shardgupta merged commit 03b6fab into babelfish-for-postgresql:BABEL_5_X_DEV Jan 8, 2025
45 checks passed
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