Generic db source plugin decimal data type doesn't support integers when sourcing from number data type
Description
Release Notes
is blocked by
Activity
Sean Zhou January 7, 2022 at 6:55 PM
created https://cdap.atlassian.net/browse/PLUGIN-1027 accordinly
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:
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
@Ankit Jain - can this happen with multidb plugin as well?
Ankit Jain December 7, 2021 at 4:16 PMEdited
Thanks Robin, looks good. Yes, it only pertains to generic DB source.
Robin Rielley December 7, 2021 at 3:53 PM
@Ankit Jain 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. “
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'`