Skip to content

typmod handling for aggregate functions. #3800

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

Open
wants to merge 17 commits into
base: BABEL_5_X_DEV
Choose a base branch
from

Conversation

Yvinayak07
Copy link
Contributor

@Yvinayak07 Yvinayak07 commented Jun 2, 2025

Issue

In resolve_numeric_typmod_from_exp we missed the handling for typmod calculation for some aggregate functions like COUNT(), COUNT_BIG(), STRING_AGG().

2. Changes made to fix the issues

Added handling for COUNT(), COUNT_BIG() and STRING_AGG() aggregates in T_Aggref node

Issues Resolved

Task: BABEL-5882

Authored-by: yashneet vinayak [email protected]
Signed-off-by: yashneet vinayak [email protected]

Test Scenarios Covered

  • Use case based - YES

  • Boundary conditions - YESS

  • Arbitrary inputs - YES

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • 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

coveralls commented Jun 4, 2025

Pull Request Test Coverage Report for Build 15576705969

Warning: 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

  • 21 of 24 (87.5%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 75.513%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contrib/babelfishpg_tsql/src/pltsql_coerce.c 21 24 87.5%
Totals Coverage Status
Change from base Build 15555865818: 0.03%
Covered Lines: 48837
Relevant Lines: 64674

💛 - Coveralls

yashneet vinayak and others added 9 commits June 6, 2025 08:30
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
…her branch is of smallmoney/money. (babelfish-for-postgresql#3719)

Currently, we treat typmod for smallmoney/money datatype as default which leads to output differences in many cases.

Following are the fixes introduced in this PR :

Introduce typmod handling for smallmoney/money datatype for objects like table/procedure/views/functions/casts and handling their upgrade scenarios.
We are also handling p&s for declared variables, nested case expressions and unions having smallmoney/money as one of it's node.
It also takes case of round vs truncation behaviour around edge cases for fixeddecimal multiplication
Money/smallmoney and Numeric Arithmetic operations - precision and sclae correction and fixing TDS protocol Errors.
T_Param node handling for fixeddecimal dataypes (money and smallmoney) when numeric is another operand.
T_Aggref handling for Sum/Avg for fixeddecimal and other fixed length datatypes when numeric is another operand.
Handing typmod for smallmoney/money in pg catalogs for views metadata and during dump-restore.
Handling money/smallmoney typmod and fixeddecimal typmodin during dump-restore and by-passing typmod while deparsing for ISC check constraint.
Avoiding crashes and wrong results by updating sanity checks and setting intermittent result size appropirately for bigint and fixeddecimal multiplication.
Signed-off-by: Tanya Gupta [email protected]

Engine PR : babelfish-for-postgresql/postgresql_modified_for_babelfish#575
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
yashneet vinayak added 2 commits June 9, 2025 05:49
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
else if (param->paramtype == INT2OID)
return ((SMALLINT_PRECISION_RADIX << 16) | 0) + VARHDRSZ;
return DEFAULT_SMALLINT_TYPMOD;
else if (plan && (*common_utility_plugin_ptr->is_tsql_tinyint_datatype) (param->paramtype))
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to check for plan here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed plan check.

yashneet vinayak added 6 commits June 10, 2025 08:15
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
Signed-off-by: yashneet vinayak <[email protected]>
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.

3 participants