[SPARK-21837][SQL][TESTS] UserDefinedTypeSuite Local UDTs not actually testing what it intends

## What changes were proposed in this pull request?

Adjust Local UDTs test to assert about results, and fix index of vector column. See JIRA for details.

## How was this patch tested?

Existing tests.

Author: Sean Owen <sowen@cloudera.com>

Closes #19053 from srowen/SPARK-21837.
This commit is contained in:
Sean Owen 2017-08-25 13:29:40 -07:00 committed by gatorsmile
parent 51620e288b
commit 1a598d717c

View file

@ -203,12 +203,12 @@ class UserDefinedTypeSuite extends QueryTest with SharedSQLContext with ParquetT
// Tests to make sure that all operators correctly convert types on the way out.
test("Local UDTs") {
val df = Seq((1, new UDT.MyDenseVector(Array(0.1, 1.0)))).toDF("int", "vec")
df.collect()(0).getAs[UDT.MyDenseVector](1)
df.take(1)(0).getAs[UDT.MyDenseVector](1)
df.limit(1).groupBy('int).agg(first('vec)).collect()(0).getAs[UDT.MyDenseVector](0)
df.orderBy('int).limit(1).groupBy('int).agg(first('vec)).collect()(0)
.getAs[UDT.MyDenseVector](0)
val vec = new UDT.MyDenseVector(Array(0.1, 1.0))
val df = Seq((1, vec)).toDF("int", "vec")
assert(vec === df.collect()(0).getAs[UDT.MyDenseVector](1))
assert(vec === df.take(1)(0).getAs[UDT.MyDenseVector](1))
checkAnswer(df.limit(1).groupBy('int).agg(first('vec)), Row(1, vec))
checkAnswer(df.orderBy('int).limit(1).groupBy('int).agg(first('vec)), Row(1, vec))
}
test("UDTs with JSON") {