Skip to content

Commit e418358

Browse files
author
Davies Liu
committed
fix GetStructField
1 parent 88b2107 commit e418358

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeExtractors.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,19 @@ case class GetStructField(child: Expression, ordinal: Int, name: Option[String]
115115

116116
override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String = {
117117
nullSafeCodeGen(ctx, ev, eval => {
118-
s"""
119-
if ($eval.isNullAt($ordinal)) {
120-
${ev.isNull} = true;
121-
} else {
118+
if (nullable) {
119+
s"""
120+
if ($eval.isNullAt($ordinal)) {
121+
${ev.isNull} = true;
122+
} else {
123+
${ev.value} = ${ctx.getValue(eval, dataType, ordinal.toString)};
124+
}
125+
"""
126+
} else {
127+
s"""
122128
${ev.value} = ${ctx.getValue(eval, dataType, ordinal.toString)};
123-
}
124-
"""
129+
"""
130+
}
125131
})
126132
}
127133
}

0 commit comments

Comments
 (0)