scruz-denodo opened a new issue, #1523: URL: https://github.com/apache/arrow-java/issues/1523
### Describe the bug, including details regarding any error messages, version, and platform. ### Describe the bug, including details regarding any error messages, version, and platform. When a Flight SQL server answers an update with `record_count = -1`, `PreparedStatement.executeUpdate()` and `Statement.executeUpdate` fails with a `NullPointerException` instead of returning a count. Avatica takes an update count of `-1` as the statement returned a result set, builds an `AvaticaResultSet `and a NPE is thrown because the signature of an update is `null`. The [protocol](https://arrow.apache.org/docs/format/FlightSql.html#protocol-buffer-definitions) indicates that `-1` means unknown > message DoPutUpdateResult { > // The number of records updated. A return value of -1 represents > // an unknown updated record count. > int64 record_count = 1; > } #### Reproduce For example with the following test. ``` java @Test public void testUpdateQueryWithUnknownCountReturnsZero() throws SQLException { // A server may answer -1 when it does not know the count, as for DDL. String query = "Fake DDL with unknown count"; PRODUCER.addUpdateQuery(query, /*updatedRows*/ -1); try (final PreparedStatement stmt = connection.prepareStatement(query)) { assertEquals(0, stmt.executeUpdate()); } } ``` #### Actual The NPE error ``` java.lang.NullPointerException: Cannot read field "columns" because "signature" is null at org.apache.arrow.driver.jdbc.shaded.org.apache.calcite.avatica.AvaticaResultSet.<init>(AvaticaResultSet.java:85) at org.apache.arrow.driver.jdbc.ArrowFlightJdbcVectorSchemaRootResultSet.<init>(ArrowFlightJdbcVectorSchemaRootResultSet.java:60) at org.apache.arrow.driver.jdbc.ArrowFlightJdbcFlightStreamResultSet.<init>(ArrowFlightJdbcFlightStreamResultSet.java:74) at org.apache.arrow.driver.jdbc.ArrowFlightJdbcFactory.newResultSet(ArrowFlightJdbcFactory.java:108) at org.apache.arrow.driver.jdbc.ArrowFlightJdbcFactory.newResultSet(ArrowFlightJdbcFactory.java:34) at org.apache.arrow.driver.jdbc.shaded.org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:568) at org.apache.arrow.driver.jdbc.shaded.org.apache.calcite.avatica.AvaticaPreparedStatement.executeLargeUpdate(AvaticaPreparedStatement.java:152) at org.apache.arrow.driver.jdbc.shaded.org.apache.calcite.avatica.AvaticaPreparedStatement.executeUpdate(AvaticaPreparedStatement.java:147) ``` #### Suggested fix Normalize to `0` when the `record_count` is lower than that value at `ArrowFlightSqlClientHandler`. -- 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]
