cloud-fan commented on code in PR #37165:
URL: https://github.com/apache/spark/pull/37165#discussion_r918669931


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/complexTypesSuite.scala:
##########
@@ -138,33 +138,33 @@ class ComplexTypesSuite extends PlanTest with 
ExpressionEvalHelper {
           "att1", $"id",
           "att2", $"id" * $"id")),
         CreateNamedStruct(Seq(
-          "att1", $"id" + 1,
-          "att2", ($"id" + 1) * ($"id" + 1))
+          "att1", $"id" + 1L,
+          "att2", $"id")
        ))
       ) as "arr"
     )
-    val query = rel
-      .select(
-        GetArrayStructFields($"arr", StructField("att1", LongType, false), 0, 
1, false) as "a1",
-        GetArrayItem($"arr", 1) as "a2",
-        GetStructField(GetArrayItem($"arr", 1), 0, None) as "a3",
-        GetArrayItem(
-          GetArrayStructFields($"arr",
-            StructField("att1", LongType, false),
-            0,
-            1,
-            false),
-          1) as "a4")
-
-    val expected = relation
-      .select(
-        CreateArray(Seq($"id", $"id" + 1L)) as "a1",
-        CreateNamedStruct(Seq(
-          "att1", ($"id" + 1L),
-          "att2", (($"id" + 1L) * ($"id" + 1L)))) as "a2",
-        ($"id" + 1L) as "a3",
-        ($"id" + 1L) as "a4")

Review Comment:
   The previous test already exposed the problem: `$"id" + 1` is repeated many 
times, which can be a big problem if it's `expensive_udf($"id")`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to