Generic db source plugin decimal data type doesn't support integers when sourcing from number data type

Description

This is experienced in case of using generic db source plugin with oracle db.
To reproduce:-
1. Create a table which has a column precision set, for eg,

CREATE TABLE ORDERS(QTY NUMBER(30, 6))


2. Insert integers into that column.

INSERT INTO ORDERS(QTY) VALUES(15)


3. Use generic db source to sample that data.

Error :- `io.cdap.cdap.api.data.format.UnexpectedFormatException: Field 'QTY' has scale '0' which is not equal to schema scale '6'`

Release Notes

Improved the generic Database source plugin to correctly read data when the data type is NUMBER, scale is set, and the data contains integer values.

Activity

Show:

Sean Zhou January 7, 2022 at 6:55 PM

Sean Zhou January 7, 2022 at 6:53 PM

yes, after looking at the multidb plugin source, the issue will apply there , need some fix for below line:

https://github.com/data-integrations/multi-table-plugins/blob/develop/src/main/java/io/cdap/plugin/format/DBTypes.java#L138

 

mainly CDAP require decimal value to be set has the same scale as the schema, we should not directly convert the BigDecimal value got from DB query resultset , its scale is same as the value scale ( for example, 12.1 will have scale 1 even its schema is decimal (19, 2) )

Amit Virmani January 7, 2022 at 5:58 PM

- can this happen with multidb plugin as well?

Ankit Jain December 7, 2021 at 4:16 PM
Edited

Thanks Robin, looks good. Yes, it only pertains to generic DB source.

Robin Rielley December 7, 2021 at 3:53 PM

Thanks. Does this only pertain to generic DB sources and not sinks?

I made some tiny edits: “Improved the generic Database source plugin to correctly read data when the data type is NUMBER, scale is set, and the data contains integer values. “



Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Affects versions

Priority

More fields

Created December 3, 2021 at 4:46 AM
Updated February 20, 2022 at 2:29 PM
Resolved December 3, 2021 at 4:50 AM