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 to "BigDecimal has mismatching scale value for given Decimal schema" #89
base: master
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
Hey @patelliandrea, It looks like you haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here. Once you've signed reply with Appreciation of efforts, clabot |
ok to test |
@@ -322,7 +323,12 @@ private static void convertFieldValue(ResultSet resultSet, int col, int colType, | |||
|
|||
case Types.NUMERIC: | |||
case Types.DECIMAL: { | |||
colValue = resultSet.getBigDecimal(col); | |||
int scale = resultSet.getMetaData().getScale(col); |
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 test this change in JdbcSourceTaskConversionTest where we test a bunch of other conversions?
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.
Looks like we only need scale when the value is not NULL.
I suggest placing this in the corresponding else clause.
Hi, I've removed the double ; |
@ConfluentCLABot [clabot:check] |
@confluentinc It looks like @patelliandrea just signed our Contributor License Agreement. 👍 Always at your service, clabot |
@patelliandrea I was curious about additional tests that actually trigger the need for this. I know we validate the scale in the logical type conversion which is why this is needed, but I'm not sure when it is occurring. |
@ewencp I've actually encountered the ArithmeticException because the conversion needed rounding so right now I'm using setScale with an hardcoded rounding mode, I'm working in order to make the rounding mode configurable. |
if (bigDecimalValue == null) | ||
colValue = null; | ||
else | ||
colValue = resultSet.getBigDecimal(col).setScale(scale); |
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.
Why do you need to get the value twice? I believe you already have it in bigDecimalValue. Which is why I suggest:
colValue = bigDecimalValue.setScale(scale);
|
Fix to issue #44 as suggested in the comments