fredjoonpark opened a new pull request, #1554: URL: https://github.com/apache/arrow-java/pull/1554
## What's Changed The Flight SQL JDBC driver sign-extended `UInt8` and `UInt32` values, wrapped `UInt64` values above `Long.MAX_VALUE` in getters whose return type can hold them, threw `ClassCastException` from `getObject(i, BigInteger.class)`, and reported `isSigned()` as false for every column. The change is in `flight/flight-sql-jdbc-core`: * **`ArrowFlightJdbcNumericGetter`**: zero-extends the `UInt8` and `UInt32` holders, so `getLong`, `getString`, `getBigDecimal`, `getDouble` and `getFloat` (and `getShort`/`getInt` for `UInt8`) return the exact value. * **`ArrowFlightJdbcBaseIntVectorAccessor`**: `getBigDecimal`, `getDouble` and `getFloat` read `UInt64` values above `Long.MAX_VALUE` as unsigned. The deprecated `getBigDecimal(columnIndex, scale)` is built on the exact `getBigDecimal()` instead of `getDouble()`. `getObject(i, BigInteger.class)` returns the value. * **`ConvertUtils`**: sets `signed` from the Arrow type, matching the parameter converters: `Int` follows its flag, `FloatingPoint` and `Decimal` are signed, everything else isn't. Two behaviours change for signed columns. `isSigned()` becomes true for signed numeric columns, which changes the types callers derive from it; for example, Spark infers `IntegerType` and `LongType` for signed `INTEGER` and `BIGINT` columns instead of `LongType` and `DecimalType(20,0)`. The deprecated scaled `getBigDecimal` becomes exact for values above 2^53. **This contains breaking changes.** Unchanged, and left for #1553 because fixing them means throwing or changing a returned class: narrowing getters still truncate values that don't fit, and `getObject` (all widths) and `getLong` (`UInt64` above `Long.MAX_VALUE`) still return the same-width signed value. ### Testing * `ArrowFlightJdbcBaseIntVectorAccessorTest`: for all eight integer vector types, `getByte`, `getShort`, `getInt`, `getLong`, `getBigDecimal`, `getString`, `getFloat`, `getDouble` and `getObject(i, BigInteger.class)` are checked against the value read from the vector, over values that include each type's maximum and sign bit. * `ArrowFlightJdbcBaseIntVectorAccessorUnitTest`: the scaled `getBigDecimal` for a `BIGINT` above 2^53, and `getObject(i, BigInteger.class)` for null. * `ConvertUtilsTest`: for 22 Arrow types, column `signed` is as expected and matches the parameter metadata. * `ResultSetMetadataTest`: `isSigned()` for signed, unsigned and non-numeric columns, from a prepared statement before execution and from its result set. * `ResultSetTest`: through the driver, `UInt8`, `UInt16`, `UInt32` and `UInt64` columns holding each type's maximum and its sign bit alone return the exact value from `getString`, `getBigDecimal`, the scaled `getBigDecimal`, `getDouble`, `getObject(i, BigInteger.class)`, `getObject(i, BigDecimal.class)` and, where it fits, `getLong`. * `mvn -pl flight/flight-sql-jdbc-core verify`: 1461 tests, 0 failures, 0 errors; the 46 skipped are existing `@Disabled` or assumption-guarded tests in `ArrowFlightConnectionPropertyTest`, `ArrowFlightJdbcTimeStampVectorAccessorTest` and `ArrowFlightPreparedStatementTest`. * Not tested end to end against a real Flight SQL server. Closes #1552. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
