Skip to content

Commit 28b3c2e

Browse files
committed
Fixes #16
This fix adds user-friendly error for the case when field names in data class and respective field names in dataset are not consistent. Signed-off-by: Pasha Finkelshteyn <asm0dey@jetbrains.com>
1 parent 79f711c commit 28b3c2e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ object KotlinReflection extends KotlinReflection {
655655
val fields = properties.map { prop =>
656656
val fieldName = prop.getName
657657
val maybeField = dataType.dt.fields.find(it => it.name == fieldName)
658+
if (maybeField.isEmpty)
659+
throw new IllegalArgumentException(s"Field $fieldName is not found among available fields, which are: ${dataType.dt.fields.map(_.name).mkString(", ")}")
658660
val propClass = maybeField.map(it => it.dataType.asInstanceOf[DataTypeWithClass].cls).get
659661
val propDt = maybeField.map(it => it.dataType.asInstanceOf[DataTypeWithClass]).get
660662

0 commit comments

Comments
 (0)