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 inferring type of decimals with leading zeros in MongoDB #19068

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

nineinchnick
Copy link
Member

@nineinchnick nineinchnick commented Sep 18, 2023

Description

Trying to read collections with fractional decimal values like 0.03 was throwing an exception.

Java's BigDecimal.precision() returns precision for the unscaled value, so it skips leading zeros. SQL decimal's precision must include leading zeros in values less than 1.

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

# MongoDB
* Fix mapping MongoDB `Decimal128` values with leading zeros in decimal part. ({issue}`19068`)

@cla-bot cla-bot bot added the cla-signed label Sep 18, 2023
@github-actions github-actions bot added the mongodb MongoDB connector label Sep 18, 2023
@nineinchnick
Copy link
Member Author

@SemionPar PTAL also, you're not in https://github.com/orgs/trinodb/teams/contributors so I can't add you as a reviewer. @wendigo @hashhar can you maybe add Semion there? Or only org admins can?

@hashhar
Copy link
Member

hashhar commented Sep 19, 2023

People get added (automatically) after they've submitted and merged a PR. No exceptions.

@hashhar hashhar requested a review from ebyhr September 19, 2023 05:59
@nineinchnick nineinchnick force-pushed the mongodb-decimal-precision branch from ddcfd8d to f29ad97 Compare September 19, 2023 11:41
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

LGTM

It'll be useful to audit whether existing type mapping tests include values < 1 for other connectors as well. e.g. BigQuery also goes via BigDecimal (though we don't need to infer the precision and scale there).

@hashhar
Copy link
Member

hashhar commented Sep 20, 2023

@ebyhr Do you want to take a look?

@hashhar hashhar merged commit 917be6e into trinodb:master Sep 20, 2023
@github-actions github-actions bot added this to the 427 milestone Sep 20, 2023
@nineinchnick nineinchnick deleted the mongodb-decimal-precision branch September 20, 2023 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed mongodb MongoDB connector
Development

Successfully merging this pull request may close these issues.

3 participants