@@ -13,6 +13,7 @@ import org.apache.arrow.vector.Float8Vector
13
13
import org.apache.arrow.vector.IntVector
14
14
import org.apache.arrow.vector.LargeVarBinaryVector
15
15
import org.apache.arrow.vector.LargeVarCharVector
16
+ import org.apache.arrow.vector.NullVector
16
17
import org.apache.arrow.vector.SmallIntVector
17
18
import org.apache.arrow.vector.TimeMicroVector
18
19
import org.apache.arrow.vector.TimeMilliVector
@@ -172,6 +173,10 @@ private fun StructVector.values(range: IntRange): List<Map<String, Any?>?> = ran
172
173
getObject(it)
173
174
}
174
175
176
+ private fun NullVector.values (range : IntRange ): List <Nothing ?> = range.map {
177
+ getObject(it) as Nothing?
178
+ }
179
+
175
180
private fun VarCharVector.values (range : IntRange ): List <String ?> = range.map {
176
181
if (isNull(it)) {
177
182
null
@@ -204,6 +209,12 @@ private fun LargeVarCharVector.values(range: IntRange): List<String?> = range.ma
204
209
}
205
210
}
206
211
212
+ internal fun nothingType (nullable : Boolean ): KType = if (nullable) {
213
+ typeOf<List <Nothing ?>>()
214
+ } else {
215
+ typeOf<List <Nothing >>()
216
+ }.arguments.first().type!!
217
+
207
218
private inline fun <reified T > List<T?>.withTypeNullable (
208
219
expectedNulls : Boolean ,
209
220
nullabilityOptions : NullabilityOptions ,
@@ -212,6 +223,15 @@ private inline fun <reified T> List<T?>.withTypeNullable(
212
223
return this to typeOf<T >().withNullability(nullable)
213
224
}
214
225
226
+ @JvmName(" withTypeNullableNothingList" )
227
+ private fun List<Nothing?>.withTypeNullable (
228
+ expectedNulls : Boolean ,
229
+ nullabilityOptions : NullabilityOptions ,
230
+ ): Pair <List <Nothing ?>, KType> {
231
+ val nullable = nullabilityOptions.applyNullability(this , expectedNulls)
232
+ return this to nothingType(nullable)
233
+ }
234
+
215
235
private fun readField (root : VectorSchemaRoot , field : Field , nullability : NullabilityOptions ): AnyBaseCol {
216
236
try {
217
237
val range = 0 until root.rowCount
@@ -245,6 +265,7 @@ private fun readField(root: VectorSchemaRoot, field: Field, nullability: Nullabi
245
265
is TimeStampMilliVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
246
266
is TimeStampSecVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
247
267
is StructVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
268
+ is NullVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
248
269
else -> {
249
270
throw NotImplementedError (" reading from ${vector.javaClass.canonicalName} is not implemented" )
250
271
}
0 commit comments