Skip to content

Commit 4460233

Browse files
committed
reflect review comments
1 parent d8d3900 commit 4460233

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,19 @@ class DataFrameComplexTypeSuite extends QueryTest with SharedSparkSession {
7373

7474
test("SPARK-29503 nest unsafe struct inside safe array") {
7575
withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> "false") {
76-
val exampleDS = spark.sparkContext.parallelize(Seq(Seq(1, 2, 3))).toDF("items")
76+
val df = spark.sparkContext.parallelize(Seq(Seq(1, 2, 3))).toDF("items")
7777

7878
// items: Seq[Int] => items.map { item => Seq(Struct(item)) }
79-
val result = exampleDS.select(
79+
val result = df.select(
8080
new Column(MapObjects(
8181
(item: Expression) => array(struct(new Column(item))).expr,
8282
$"items".expr,
83-
exampleDS.schema("items").dataType.asInstanceOf[ArrayType].elementType
83+
df.schema("items").dataType.asInstanceOf[ArrayType].elementType
8484
)) as "items"
8585
).collect()
8686

87-
def getValueInsideDepth(result: Row, index: Int): Int = {
88-
// expected output:
89-
// WrappedArray([WrappedArray(WrappedArray([1]), WrappedArray([2]), WrappedArray([3]))])
90-
result.getSeq[mutable.WrappedArray[_]](0)(index)(0)
91-
.asInstanceOf[GenericRowWithSchema].getInt(0)
92-
}
93-
9487
assert(result.size === 1)
95-
assert(getValueInsideDepth(result.head, 0) === 1)
96-
assert(getValueInsideDepth(result.head, 1) === 2)
97-
assert(getValueInsideDepth(result.head, 2) === 3)
88+
assert(result === Row(Seq(Seq(Row(1)), Seq(Row(2)), Seq(Row(3)))) :: Nil)
9889
}
9990
}
10091
}

0 commit comments

Comments
 (0)