Skip to content

Commit 1a598d7

Browse files
srowengatorsmile
authored andcommitted
[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 <[email protected]> Closes apache#19053 from srowen/SPARK-21837.
1 parent 51620e2 commit 1a598d7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sql/core/src/test/scala/org/apache/spark/sql/UserDefinedTypeSuite.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ class UserDefinedTypeSuite extends QueryTest with SharedSQLContext with ParquetT
203203

204204
// Tests to make sure that all operators correctly convert types on the way out.
205205
test("Local UDTs") {
206-
val df = Seq((1, new UDT.MyDenseVector(Array(0.1, 1.0)))).toDF("int", "vec")
207-
df.collect()(0).getAs[UDT.MyDenseVector](1)
208-
df.take(1)(0).getAs[UDT.MyDenseVector](1)
209-
df.limit(1).groupBy('int).agg(first('vec)).collect()(0).getAs[UDT.MyDenseVector](0)
210-
df.orderBy('int).limit(1).groupBy('int).agg(first('vec)).collect()(0)
211-
.getAs[UDT.MyDenseVector](0)
206+
val vec = new UDT.MyDenseVector(Array(0.1, 1.0))
207+
val df = Seq((1, vec)).toDF("int", "vec")
208+
assert(vec === df.collect()(0).getAs[UDT.MyDenseVector](1))
209+
assert(vec === df.take(1)(0).getAs[UDT.MyDenseVector](1))
210+
checkAnswer(df.limit(1).groupBy('int).agg(first('vec)), Row(1, vec))
211+
checkAnswer(df.orderBy('int).limit(1).groupBy('int).agg(first('vec)), Row(1, vec))
212212
}
213213

214214
test("UDTs with JSON") {

0 commit comments

Comments
 (0)