LuciferYang commented on code in PR #45896:
URL: https://github.com/apache/spark/pull/45896#discussion_r1713304198


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/ExecuteImmediateEndToEndSuite.scala:
##########
@@ -36,4 +37,30 @@ class ExecuteImmediateEndToEndSuite extends QueryTest with 
SharedSparkSession {
       spark.sql("DROP TEMPORARY VARIABLE IF EXISTS parm;")
     }
   }
+
+  test("EXEC IMMEDIATE STACK OVERFLOW") {
+    try {
+      spark.sql("DECLARE parm = 1;")
+      val query = (1 to 20000).map(x => "SELECT 1 as a").mkString(" UNION ALL 
")
+      Seq(
+        s"EXECUTE IMMEDIATE '$query'",
+        s"EXECUTE IMMEDIATE '$query' INTO parm").foreach { q =>
+        val e = intercept[ParseException] {
+          spark.sql(q)
+        }
+
+        checkError(
+          exception = intercept[ParseException](sql(query).collect()),

Review Comment:
   On the other hand, I would like to know if this test requires a lot of 
memory? I encountered a test failure in the maven daily test yesterday:
   
   - https://github.com/apache/spark/actions/runs/10339976899/job/28619998545
   
   
![image](https://github.com/user-attachments/assets/6b000df8-2505-4ae0-9106-e3c09ae10ec7)
   
   
   This is the first time I have seen this test case fail, and I am not yet 
sure about the root cause of the failure. Additionally, I tried testing it 
locally, but there were no successful cases:
   
   ```
   build/mvn clean install -pl sql/core -am -Dtest=none 
-DwildcardSuites=org.apache.spark.sql.execution.ExecuteImmediateEndToEndSuite
   ```
   
   or 
   
   ```
   git reset --hard fe05eb8fa3b205b3212c25541e32b34f2167b540 //  [SPARK-47741] 
Added stack overflow handling in parser
   build/mvn clean install -pl sql/core -am -Dtest=none 
-DwildcardSuites=org.apache.spark.sql.execution.ExecuteImmediateEndToEndSuite
   ```
   
   ```
   ExecuteImmediateEndToEndSuite:
   15:43:22.514 WARN org.apache.spark.util.Utils: Your hostname, 
MacBook-Pro.local resolves to a loopback address: 127.0.0.1; using 
172.22.200.238 instead (on interface en0)
   
   15:43:22.515 WARN org.apache.spark.util.Utils: Set SPARK_LOCAL_IP if you 
need to bind to another address
   
   15:43:22.646 WARN org.apache.hadoop.util.NativeCodeLoader: Unable to load 
native-hadoop library for your platform... using builtin-java classes where 
applicable
   
   - SPARK-47033: EXECUTE IMMEDIATE USING does not recognize session variable 
names
   - EXEC IMMEDIATE STACK OVERFLOW *** FAILED ***
     Expected exception org.apache.spark.sql.catalyst.parser.ParseException to 
be thrown, but org.apache.spark.sql.AnalysisException was thrown 
(ExecuteImmediateEndToEndSuite.scala:48)
   15:43:25.287 WARN 
org.apache.spark.sql.execution.ExecuteImmediateEndToEndSuite: 
   
   ===== POSSIBLE THREAD LEAK IN SUITE 
o.a.s.sql.execution.ExecuteImmediateEndToEndSuite, threads: rpc-boss-3-1 
(daemon=true), shuffle-boss-6-1 (daemon=true) =====
   ```



-- 
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