Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19603#discussion_r147580091
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
---
@@ -591,18 +591,40 @@ case class MapObjects private(
case _ => inputData.dataType
}
- val (getLength, getLoopVar) = inputDataType match {
+ val (getLength, prepareLoop, getLoopVar) = inputDataType match {
case ObjectType(cls) if classOf[Seq[_]].isAssignableFrom(cls) =>
- s"${genInputData.value}.size()" ->
s"${genInputData.value}.apply($loopIndex)"
+ val it = ctx.freshName("it")
+ (
+ s"${genInputData.value}.size()",
+ s"scala.collection.Iterator $it =
${genInputData.value}.toIterator();",
+ s"$it.next()"
+ )
case ObjectType(cls) if cls.isArray =>
- s"${genInputData.value}.length" ->
s"${genInputData.value}[$loopIndex]"
+ (
+ s"${genInputData.value}.length",
+ "",
+ s"${genInputData.value}[$loopIndex]"
+ )
case ObjectType(cls) if
classOf[java.util.List[_]].isAssignableFrom(cls) =>
--- End diff --
The legal external typea for catalyst array are scala `Seq` and java
`List`, so we don't need to match a more general type here.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]