Skip to content

bug fix for using set-type when it's the first directive in the recipie#688

Open
minurajeeve wants to merge 2 commits intodevelopfrom
add-precision-option-in-decimal-bug-fix
Open

bug fix for using set-type when it's the first directive in the recipie#688
minurajeeve wants to merge 2 commits intodevelopfrom
add-precision-option-in-decimal-bug-fix

Conversation

@minurajeeve
Copy link
Contributor

No description provided.

@minurajeeve minurajeeve added the build Triggers unit test build label Dec 5, 2023
@minurajeeve minurajeeve requested a review from vanathi-g December 5, 2023 16:02
Pair<Integer, Integer> scaleAndPrecision = getPrecisionAndScale(fieldSchema);
Integer inputSchemaScale = scaleAndPrecision.getSecond();
Integer inputSchemaPrecision = scaleAndPrecision.getFirst();
if (type.equalsIgnoreCase("decimal") && field.getSchema().isNullable()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens when schema is non nullable but set type directive is applied with 'decimal' as the type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the schema is non nullable it will skip this if condition and will go to the return statement in line no:167. By default outputScale and outputPrecision are the scale and precision specified by the user. In this case we don't validate if the user specified scale and precision values clash with the original scale and precision values of that column.

Integer inputSchemaScale = scaleAndPrecision.getSecond();
Integer inputSchemaPrecision = scaleAndPrecision.getFirst();
if (type.equalsIgnoreCase("decimal") && field.getSchema().isNullable()) {
Schema fieldSchema = field.getSchema().getNonNullable();
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I think this giant block that calculates precision and scale to use can be moved to a different function. Can refactor the function used in .map()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@minurajeeve minurajeeve force-pushed the add-precision-option-in-decimal-bug-fix branch from d07f02d to 6ffcfaa Compare January 2, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Triggers unit test build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments