diff --git a/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/DecimalAvaticaParameterConverter.java b/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/DecimalAvaticaParameterConverter.java index 92faa119bd..cd93673018 100644 --- a/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/DecimalAvaticaParameterConverter.java +++ b/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/DecimalAvaticaParameterConverter.java @@ -17,6 +17,7 @@ package org.apache.arrow.driver.jdbc.converter.impl; import java.math.BigDecimal; +import org.apache.arrow.vector.Decimal256Vector; import org.apache.arrow.vector.DecimalVector; import org.apache.arrow.vector.FieldVector; import org.apache.arrow.vector.types.pojo.ArrowType; @@ -35,6 +36,9 @@ public boolean bindParameter(FieldVector vector, TypedValue typedValue, int inde if (vector instanceof DecimalVector) { ((DecimalVector) vector).setSafe(index, value); return true; + } else if (vector instanceof Decimal256Vector) { + ((Decimal256Vector) vector).setSafe(index, value); + return true; } return false; } diff --git a/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowFlightPreparedStatementTest.java b/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowFlightPreparedStatementTest.java index 73ece46403..da04470198 100644 --- a/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowFlightPreparedStatementTest.java +++ b/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowFlightPreparedStatementTest.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.Date; @@ -317,6 +318,7 @@ public void testUpdateQueryWithParameters() throws SQLException { @Test public void testUpdateQueryWithBatchedParameters() throws SQLException { String query = "Fake update with batched parameters"; + BigDecimal decimal = new BigDecimal("123456789012345678901234567890123456789.01"); Schema parameterSchema = new Schema( Arrays.asList( @@ -324,22 +326,24 @@ public void testUpdateQueryWithBatchedParameters() throws SQLException { new Field( "", FieldType.nullable(ArrowType.List.INSTANCE), - Collections.singletonList(Field.nullable("", Types.MinorType.INT.getType()))))); + Collections.singletonList(Field.nullable("", Types.MinorType.INT.getType()))), + Field.nullable("", new ArrowType.Decimal(76, 2, 256)))); List> expected = Arrays.asList( - Arrays.asList(new Text("foo"), new Integer[] {1, 2, null}), - Arrays.asList(new Text("bar"), new Integer[] {0, -1, 100000})); + Arrays.asList(new Text("foo"), new Integer[] {1, 2, null}, decimal), + Arrays.asList(new Text("bar"), new Integer[] {0, -1, 100000}, decimal.negate())); PRODUCER.addUpdateQuery(query, /*updatedRows*/ 42); PRODUCER.addExpectedParameters(query, parameterSchema, expected); try (final PreparedStatement stmt = connection.prepareStatement(query)) { - // TODO: make sure this is validated on the server too stmt.setString(1, "foo"); stmt.setArray(2, connection.createArrayOf("INTEGER", new Integer[] {1, 2, null})); + stmt.setBigDecimal(3, decimal); stmt.addBatch(); stmt.setString(1, "bar"); stmt.setArray(2, connection.createArrayOf("INTEGER", new Integer[] {0, -1, 100000})); + stmt.setBigDecimal(3, decimal.negate()); stmt.addBatch(); int[] updated = stmt.executeBatch(); assertEquals(42, updated[0]);