This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-java.git
The following commit(s) were added to refs/heads/main by this push:
new f69bf2969 MINOR: Support Decimal256 in Flight SQL JDBC parameter
binding (#1521)
f69bf2969 is described below
commit f69bf296911bac7f6dbe01d3198217fe96a643a7
Author: Robert Kruszewski <[email protected]>
AuthorDate: Thu Nov 26 12:04:33 2026 +0000
MINOR: Support Decimal256 in Flight SQL JDBC parameter binding (#1521)
## What's Changed
Split out from #1228. Flight SQL JDBC parameter bindings never allowed
Decimal256.
---
.../converter/impl/DecimalAvaticaParameterConverter.java | 4 ++++
.../arrow/driver/jdbc/ArrowFlightPreparedStatementTest.java | 12 ++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
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 92faa119b..cd9367301 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 class DecimalAvaticaParameterConverter extends
BaseAvaticaParameterConver
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 2cf3e74df..cba56cbfa 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
@@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
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;
@@ -460,6 +461,7 @@ public class ArrowFlightPreparedStatementTest {
@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(
@@ -467,22 +469,24 @@ public class ArrowFlightPreparedStatementTest {
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<List<Object>> 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]);