Giter Club home page Giter Club logo

Comments (10)

erhwenkuo avatar erhwenkuo commented on July 18, 2024

I am also encountered this error message when I try to use JDBC connector of oracle db. According to Stackoverflow-Difference between number and integer datatype in oracle dictionary views, I found out the "number" type in oracle table caused this issue. In my case, I have a field "ShipAmt" (Type: Number , Scale: 3) defined in oracle, and have one record "ShipAmt=10". From oracle jdbc resultset meta data, the scale (3) is correct but the decimal value using resultset.getBigDecimal() only show scale(0) which cause value / schema mismatch validation error.
Below is a quick fix: Modify "DataConvert.convertFieldValue" method to enable "scale" check and force setting right scale number on BigDecimal object.

public class DataConverter {
private static void convertFieldValue(ResultSet resultSet, int col, int colType,
                                        Struct struct, String fieldName)
      throws SQLException, IOException {
.....
.....
case Types.NUMERIC:
      case Types.DECIMAL: {
        //check scale from meta and reflect on BigDecimal object
        int scale = resultSet.getMetaData().getScale(col);
        colValue = resultSet.getBigDecimal(col).setScale(scale);;
        break;
      }
....

from kafka-connect-jdbc.

cddr avatar cddr commented on July 18, 2024

We get this on postgres too.

from kafka-connect-jdbc.

ryananguiano avatar ryananguiano commented on July 18, 2024

This is prohibiting us from using kafka connect jdbc as a source. We are running into incorrect avro typing for decimal and boolean fields. Is this in the pipeline to get fixed soon? Or should we look to running PR code or looking for other solutions.

Thanks.

from kafka-connect-jdbc.

ewencp avatar ewencp commented on July 18, 2024

@ryananguiano There's a PR outstanding but it still needs some fixes since the current version can cause ArithmeticExceptions by reducing the precision of the BigDecimal.

from kafka-connect-jdbc.

clumsy avatar clumsy commented on July 18, 2024

I had a similar issue and as far as I was able to investigate - setting scale won't work for some JDBC sources.
One problem I had in particular was that Oracle DB will not provide proper metadata for numeric columns - especially if the column was constructed via aggregates (like sum, min, etc.). It will say the scale is 0 even though you have a floating point value as a result.

The way I was able to address some of the issues was to use an explicit CAST in my queries, where I was able to specify the precision and scale or use another data type (DOUBLE instead of NUMERIC).

Hope that helps.

from kafka-connect-jdbc.

ynaguib avatar ynaguib commented on July 18, 2024

@clumsy: how did you fix the oracle cast?
I tried Select cast( ... as integer) from tab, and nothing seems to work!

from kafka-connect-jdbc.

clumsy avatar clumsy commented on July 18, 2024

@ynaguib Using current kafka-connect-jdbc I was only able to get rid of all BigDecimals and their scale problems for Oracle jdbc by casting to FLOAT and DOUBLE (casting to INTEGER will still result in NUMERIC type).
Later I was able to come up with a more refine converter for NUMERIC type that I've described in #101.
So currently I'm using a custom build with my patch and it works just fine.

from kafka-connect-jdbc.

hanshenrik avatar hanshenrik commented on July 18, 2024

Any progress on pull request https://github.com/confluentinc/kafka-connect-jdbc/pull/89? Encountered same issue for data type Number in an Oracle DB using kafka-connect-jdbc-3.1.1.jar.

ERROR Task test-booking-source-0 threw an uncaught and unrecoverable exception (org.apache.kafka.connect.runtime.WorkerTask:142)
org.apache.kafka.connect.errors.DataException: BigDecimal has mismatching scale value for given Decimal schema
	at org.apache.kafka.connect.data.Decimal.fromLogical(Decimal.java:69)
	at org.apache.kafka.connect.json.JsonConverter$17.convert(JsonConverter.java:232)
[...]

from kafka-connect-jdbc.

shikhar avatar shikhar commented on July 18, 2024

I think @cotedm may have fixed this here https://github.com/confluentinc/kafka-connect-jdbc/pull/177/files#diff-d5992997144b4c23572648ca6331eac5R412

from kafka-connect-jdbc.

rnpridgeon avatar rnpridgeon commented on July 18, 2024

As @shikhar has pointed out PR #177 should remedy this. Since it has recently been merged I'll mark this as closed for now.

from kafka-connect-jdbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.