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

Added BBF hook to truncate numeric result to correct scale #536

Open
wants to merge 16 commits into
base: BABEL_4_X_DEV__PG_16_X
Choose a base branch
from

Conversation

rohit01010
Copy link
Contributor

@rohit01010 rohit01010 commented Feb 21, 2025

Description

For Babelfish, the expected behaviour should be for every arithmetic computation which results in numeric datatype, the result should be truncated to the correct scale. To get this behaviour added hooks at following places to truncate the result value.

  • evaluate_expr() - All the arithmetic computations that result in constant value, happens here. So added a hook to truncate the result after every such arithmetic computation.
  • ExecInterpExpr() - All the arithmetic computations other than mentioned above, happens here. So added a hook to truncate the result after every such arithmetic computation.
  • finalize_aggregate() - For aggregate functions, the final result is computed here, so added a hook to truncate the result for aggregate functions.

Also, for some nodes such as T_OpExpr, T_DistinctExpr, T_CoerceViaIO the result_typmod was directly hardcoded as -1 in PostgreSQL, Added hook pltsql_exprTypmod_hook to compute the typmod of the expression and passed those instead of -1 to avoid losing typmod information. Also, added pltsql_exprTypmod_hook to compute expression typmod for expressions whose typmod is not computed by exprTypmod.

Extension PR: babelfish-for-postgresql/babelfish_extensions#3521
Cherry-picked from: #529

Issues Resolved

BABEL-5467

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 PostgreSQL license, 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 16 commits February 21, 2025 06:35
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
…nction

Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
Signed-off-by: Rohit Bhagat <rohitbgt@amazon.com>
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