Skip to content

Commit

Permalink
Fix missing array elements. Try convert to Array after append newValue
Browse files Browse the repository at this point in the history
  • Loading branch information
hipp0gryph committed Aug 11, 2024
1 parent e93fa19 commit aec0811
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ private[xml] object StaxXmlParser extends Serializable {

case ArrayType(dt: DataType, _) =>
val values = Option(row(index))
.map(_.asInstanceOf[Array[Any]])
.getOrElse(Array.empty[Any])
.map(_.asInstanceOf[ArrayBuffer[Any]])
.getOrElse(ArrayBuffer.empty[Any])
val newValue = dt match {
case st: StructType =>
convertObjectWithAttributes(parser, st, options, attributes)
case dt: DataType =>
convertField(parser, dt, options)
}
row(index) = values :+ newValue
row(index) = (values :+ newValue).toArray

case dt: DataType =>
row(index) = convertField(parser, dt, options, attributes)
Expand All @@ -345,9 +345,9 @@ private[xml] object StaxXmlParser extends Serializable {
row(anyIndex) = newValue
case ArrayType(StringType, _) =>
val values = Option(row(anyIndex))
.map(_.asInstanceOf[Array[String]])
.getOrElse(Array.empty[String])
row(anyIndex) = values :+ newValue
.map(_.asInstanceOf[ArrayBuffer[String]])
.getOrElse(ArrayBuffer.empty[String])
row(anyIndex) = (values :+ newValue).toArray
}
} else {
StaxXmlParserUtils.skipChildren(parser)
Expand Down

0 comments on commit aec0811

Please sign in to comment.