-
Notifications
You must be signed in to change notification settings - Fork 101
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
Fixed case expression when one of the branch is NUMERIC and other is of EXACT NUMERIC. #3584
base: BABEL_5_X_DEV
Are you sure you want to change the base?
Fixed case expression when one of the branch is NUMERIC and other is of EXACT NUMERIC. #3584
Conversation
…of EXACT NUEMRIC Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
Pull Request Test Coverage Report for Build 13945425615Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
@@ -561,7 +561,7 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) | |||
Numeric num; | |||
int64 val; | |||
|
|||
if ((!(con->consttype == INT4OID) && !is_numeric_datatype(con->consttype)) || | |||
if ((!(con->consttype == INT8OID) && !(con->consttype == INT4OID) && !(con->consttype == INT2OID) && !is_numeric_datatype(con->consttype)) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fix this for UDTs as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Case
and Union
we are handling UDT's before this hook.
@@ -577,7 +577,7 @@ resolve_numeric_typmod_from_exp(Plan *plan, Node *expr) | |||
* the appropriate typmod. This process ensures correct | |||
* numeric precision handling in Babelfish TSQL operations. | |||
*/ | |||
if (plan == NULL && con->consttype == INT4OID) | |||
if (plan == NULL && (con->consttype == INT4OID || con->consttype == INT8OID || con->consttype == INT2OID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Multi-line
Signed-off-by: yashneet vinayak <[email protected]>
Issues
CASE statement doesn't gives correct typmod when one of the branch is numeric and other is of exact numeric. The precision is being set 5 and scale is set to 4 in babelfish.
So expected result (123.0000) won't fit in Numeric(5,4). So we need to figure out correct precision and scale in this case.
Changes made to fix the issues
In the tsql_select_common_typmod hook, allowed exact numeric types for calculating correct precision and scale.
Task: BABEL-5678
Authored-by: yashneet vinayak [email protected]
Signed-off-by: yashneet vinayak [email protected]
Test Scenarios Covered
**Use case based -**YES
**Boundary conditions -**YES
**Arbitrary inputs -**YES
**Negative test cases -**YES
Minor version upgrade tests -
Major version upgrade tests -
Performance tests -
Tooling impact -
**Client tests -**YES
Check List
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.