apache / apache/arrow-java

[Java][JDBC] JDBC Adapter execution failed for Mysql unsigned interger data

Open
#182 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
94
Forks
152
Avg merge
3d 16h
Merged PRs (30d)
11

Description

**Summarize**
Arrow JDBC Adapter throw exception when wrapping the mysql driver with unsigned interger data.

**Example**
create a field with INT UNSIGNED type in Mysql, one of the field value is 4294967293. when use JDBC Adapter, it will throw:
```
Caused by: java.lang.RuntimeException: Error occurred while consuming data.
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.consumeData(ArrowVectorIterator.java:117)
ArrowVectorIterator.java:117
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.load(ArrowVectorIterator.java:159)
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.next(ArrowVectorIterator.java:177)
ArrowVectorIterator.java:177
... 76 more
Caused by: java.sql.SQLDataException: Value '4294967293' is outside of valid range for type java.lang.Integer
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:115)
SQLError.java:115
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:98)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:90)
SQLError.java:90
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:64)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:74)
SQLError.java:74
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:92)
SQLExceptionsMapping.java:92
at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1431)
ResultSetImpl.java:1431
at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:830)
ResultSetImpl.java:830
at org.apache.arrow.adapter.jdbc.consumer.IntConsumer$NullableIntConsumer.consume(IntConsumer.java:56)
IntConsumer.java:56
at org.apache.arrow.adapter.jdbc.consumer.CompositeJdbcConsumer.consume(CompositeJdbcConsumer.java:46)
CompositeJdbcConsumer.java:46
at org.apache.arrow.adapter.jdbc.ArrowVectorIterator.consumeData(ArrowVectorIterator.java:106)
ArrowVectorIterator.java:106
... 78 more
Caused by: com.mysql.cj.exceptions.NumberOutOfRange: Value '4294967293' is outside of valid range for type java.lang.Integer
at com.mysql.cj.result.IntegerValueFactory.createFromLong(IntegerValueFactory.java:62)
at com.mysql.cj.result.IntegerValueFactory.createFromLong(IntegerValueFactory.java:44)
at com.mysql.cj.protocol.a.MysqlTextValueDecoder.decodeUInt4(MysqlTextValueDecoder.java:110)
```

which is thrown from https://github.com/apache/arrow/blob/c9fbc88eccd56fda27d6bc655732ed17388317ac/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/IntConsumer.java#L56

**Expected**
make jdbc adpater support unsigned datatype.
possible datatype mapping:
| SQL Type| Java Type |
|-|-|
|TINYINT UNSIGNED|java.lang.Integer|
|SMALLINT UNSIGNED|java.lang.Integer|
|MEDIUMINT UNSIGNED|java.lang.Long|
|INT UNSIGNED|java.lang.Long|
|BIGINT UNSIGNED|java.math.BigInteger|

### Component(s)

Java

Contributor guide

Open the contributing guide

Research direction

Start with java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/IntConsumer.java at line 56, then trace how JDBC SQL types are mapped to consumers. Confirm the behavior with a MySQL INT UNSIGNED value such as 4294967293; done means unsigned types are supported according to the mappings listed in the issue without the adapter throwing a range exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.