Skip to content

Commit 9cfa6ff

Browse files
authored
GH-848: TypedValue should be treated as Nullable in bind function in AvaticaParameterBinder (#849)
## What's Changed Closes #848.
1 parent 34060eb commit 9cfa6ff

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/AvaticaParameterBinder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.arrow.vector.VectorSchemaRoot;
4545
import org.apache.arrow.vector.types.pojo.ArrowType;
4646
import org.apache.calcite.avatica.remote.TypedValue;
47+
import org.checkerframework.checker.nullness.qual.Nullable;
4748

4849
/**
4950
* Convert Avatica PreparedStatement parameters from a list of TypedValue to Arrow and bind them to
@@ -108,9 +109,9 @@ public void bind(List<TypedValue> typedValues, int index) {
108109
* @param typedValue TypedValue to bind to the vector.
109110
* @param index Vector index to bind the value at.
110111
*/
111-
private void bind(FieldVector vector, TypedValue typedValue, int index) {
112+
private void bind(FieldVector vector, @Nullable TypedValue typedValue, int index) {
112113
try {
113-
if (typedValue.value == null) {
114+
if (typedValue == null || typedValue.value == null) {
114115
if (vector.getField().isNullable()) {
115116
vector.setNull(index);
116117
} else {
@@ -127,7 +128,7 @@ private void bind(FieldVector vector, TypedValue typedValue, int index) {
127128
throw new UnsupportedOperationException(
128129
String.format(
129130
"Binding value of type %s is not yet supported for expected Arrow type %s",
130-
typedValue.type, vector.getField().getType()));
131+
typedValue == null ? "null" : typedValue.type, vector.getField().getType()));
131132
}
132133
}
133134

0 commit comments

Comments
 (0)