Skip to content

Commit

Permalink
Fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Mar 8, 2018
1 parent f86f40e commit 3627dc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ case class MapObjects private(
results.asJava
} else {
val builder = Try(cls.getConstructor(Integer.TYPE)).map { constructor =>
constructor.newInstance()
constructor.newInstance(results.length.asInstanceOf[Object])
}.getOrElse {
cls.getConstructor().newInstance(results.length.asInstanceOf[Object])
cls.getConstructor().newInstance()
}.asInstanceOf[java.util.List[Any]]

results.foreach(builder.add(_))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
}

test("SPARK-23587: MapObjects should support interpreted execution") {
val customCollectionClasses = Seq(classOf[Seq[_]], classOf[scala.collection.Set[_]],
classOf[java.util.List[_]], classOf[java.util.AbstractList[_]],
classOf[java.util.AbstractSequentialList[_]], null)
val customCollectionClasses = Seq(classOf[Seq[Int]], classOf[scala.collection.Set[Int]],
classOf[java.util.List[Int]], classOf[java.util.AbstractList[Int]],
classOf[java.util.AbstractSequentialList[Int]], classOf[java.util.Vector[Int]],
classOf[java.util.Stack[Int]], null)
val function = (lambda: Expression) => Add(lambda, Literal(1))
val elementType = IntegerType
val expected = Seq(2, 3, 4)
Expand All @@ -143,6 +144,10 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
vector.add(1)
vector.add(2)
vector.add(3)
val stack = new java.util.Stack[Int]()
stack.add(1)
stack.add(2)
stack.add(3)

Seq(
(Seq(1, 2, 3), ObjectType(classOf[Seq[Int]])),
Expand Down

0 comments on commit 3627dc3

Please sign in to comment.