@@ -13,6 +13,7 @@ import org.apache.arrow.vector.Float8Vector
1313import org.apache.arrow.vector.IntVector
1414import org.apache.arrow.vector.LargeVarBinaryVector
1515import org.apache.arrow.vector.LargeVarCharVector
16+ import org.apache.arrow.vector.NullVector
1617import org.apache.arrow.vector.SmallIntVector
1718import org.apache.arrow.vector.TimeMicroVector
1819import org.apache.arrow.vector.TimeMilliVector
@@ -172,6 +173,10 @@ private fun StructVector.values(range: IntRange): List<Map<String, Any?>?> = ran
172173 getObject(it)
173174}
174175
176+ private fun NullVector.values (range : IntRange ): List <Nothing ?> = range.map {
177+ getObject(it) as Nothing?
178+ }
179+
175180private fun VarCharVector.values (range : IntRange ): List <String ?> = range.map {
176181 if (isNull(it)) {
177182 null
@@ -204,6 +209,12 @@ private fun LargeVarCharVector.values(range: IntRange): List<String?> = range.ma
204209 }
205210}
206211
212+ internal fun nothingType (nullable : Boolean ): KType = if (nullable) {
213+ typeOf<List <Nothing ?>>()
214+ } else {
215+ typeOf<List <Nothing >>()
216+ }.arguments.first().type!!
217+
207218private inline fun <reified T > List<T?>.withTypeNullable (
208219 expectedNulls : Boolean ,
209220 nullabilityOptions : NullabilityOptions ,
@@ -212,6 +223,15 @@ private inline fun <reified T> List<T?>.withTypeNullable(
212223 return this to typeOf<T >().withNullability(nullable)
213224}
214225
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+
215235private fun readField (root : VectorSchemaRoot , field : Field , nullability : NullabilityOptions ): AnyBaseCol {
216236 try {
217237 val range = 0 until root.rowCount
@@ -245,6 +265,7 @@ private fun readField(root: VectorSchemaRoot, field: Field, nullability: Nullabi
245265 is TimeStampMilliVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
246266 is TimeStampSecVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
247267 is StructVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
268+ is NullVector -> vector.values(range).withTypeNullable(field.isNullable, nullability)
248269 else -> {
249270 throw NotImplementedError (" reading from ${vector.javaClass.canonicalName} is not implemented" )
250271 }
0 commit comments