Skip to content

Commit 686c60c

Browse files
committed
fix: start to fix array of generics support
refs #64
1 parent 3f3562b commit 686c60c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

core/2.4/src/main/scala/org/apache/spark/sql/catalyst/KotlinReflection.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,20 @@ object KotlinReflection {
271271
}
272272

273273
val maybeType = predefinedDt.filter(_.dt.isInstanceOf[ArrayType]).map(_.dt.asInstanceOf[ArrayType].elementType)
274+
val reifiedElementType = maybeType match {
275+
case Some(dt: DataTypeWithClass) => dt.cls
276+
case _ => c.getComponentType
277+
}
274278
primitiveMethod.map { method =>
275279
Invoke(getPath, method, ObjectType(c))
276280
}.getOrElse {
277281
Invoke(
278282
MapObjects(
279283
p => {
280-
deserializerFor(typeToken.getComponentType, Some(p), maybeType.filter(_.isInstanceOf[ComplexWrapper]).map(_.asInstanceOf[ComplexWrapper]))
284+
deserializerFor(TypeToken.of(reifiedElementType), Some(p), maybeType.filter(_.isInstanceOf[ComplexWrapper]).map(_.asInstanceOf[ComplexWrapper]))
281285
},
282286
getPath,
283-
maybeType.filter(_.isInstanceOf[ComplexWrapper]).map(_.asInstanceOf[ComplexWrapper].dt).getOrElse(inferDataType(elementType)._1)
287+
maybeType.filter(_.isInstanceOf[ComplexWrapper]).map(_.asInstanceOf[ComplexWrapper].dt).getOrElse(inferDataType(reifiedElementType)._1)
284288
),
285289
"array",
286290
ObjectType(c)
@@ -507,7 +511,7 @@ object KotlinReflection {
507511
input :: Nil,
508512
dataType = ArrayType(dataType, nullable))
509513
} else {
510-
val next = predefinedDt.map(_.dt).filter(_.isInstanceOf[ComplexWrapper]).map(_.asInstanceOf[ComplexWrapper])
514+
val next = predefinedDt.filter(_.isInstanceOf[ComplexWrapper]).map(_.asInstanceOf[ComplexWrapper])
511515
MapObjects(serializerFor(_, elementType, next), input, ObjectType(elementType.getRawType))
512516
}
513517
}

kotlin-spark-api/2.4/src/test/kotlin/org/jetbrains/kotlinx/spark/api/ApiTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ package org.jetbrains.kotlinx.spark.api/*-
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

0 commit comments

Comments
 (0)