lidavidm commented on code in PR #13906:
URL: https://github.com/apache/arrow/pull/13906#discussion_r949269533


##########
java/adapter/jdbc/src/test/java/org/apache/arrow/adapter/jdbc/JdbcParameterBinderTest.java:
##########
@@ -483,4 +571,105 @@ <T, V extends FieldVector> void testSimpleType(ArrowType 
arrowType, int jdbcType
       assertThat(binder.next()).isFalse();
     }
   }
+
+  <T, V extends FieldVector> void testListType(ArrowType arrowType, 
TriConsumer<V, Integer, T> setValue,
+                          BiConsumer<V, Integer> setNull, List<T> values) 
throws SQLException {
+    int jdbcType = Types.ARRAY;
+    Schema schema = new Schema(Collections.singletonList(new Field("field", 
FieldType.nullable(
+            new ArrowType.List()), Collections.singletonList(
+            new Field("element", FieldType.notNullable(arrowType), null)
+    ))));
+    try (final MockPreparedStatement statement = new MockPreparedStatement();
+         final VectorSchemaRoot root = VectorSchemaRoot.create(schema, 
allocator)) {
+      final JdbcParameterBinder binder =
+          JdbcParameterBinder.builder(statement, root).bindAll().build();
+      assertThat(binder.next()).isFalse();
+
+      @SuppressWarnings("unchecked")
+      final V vector = (V) root.getVector(0);
+      final ColumnBinder columnBinder = ColumnBinder.forVector(vector);
+      assertThat(columnBinder.getJdbcType()).isEqualTo(jdbcType);
+
+      setValue.accept(vector, 0, values.get(0));
+      setValue.accept(vector, 1, values.get(1));
+      setNull.accept(vector, 2);
+      root.setRowCount(3);
+
+      assertThat(binder.next()).isTrue();
+      assertThat(statement.getParamValue(1)).isEqualTo(values.get(0));
+      assertThat(binder.next()).isTrue();
+      assertThat(statement.getParamValue(1)).isEqualTo(values.get(1));
+      assertThat(binder.next()).isTrue();
+      assertThat(statement.getParamValue(1)).isNull();
+      assertThat(statement.getParamType(1)).isEqualTo(jdbcType);
+      assertThat(binder.next()).isFalse();
+
+      binder.reset();
+
+      setNull.accept(vector, 0);
+      setValue.accept(vector, 1, values.get(2));
+      setValue.accept(vector, 2, values.get(0));
+      setValue.accept(vector, 3, values.get(2));

Review Comment:
   The empty array value isn't being used, since the testers here only access 
indices 0-2. Maybe change one of these indices to `3`?  



-- 
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]

Reply via email to