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


##########
docs/sql-error-conditions.md:
##########
@@ -756,6 +756,12 @@ Failed to rename temp file `<srcPath>` to `<dstPath>` as 
FileSystem.rename retur
 
 Failed to convert the row value `<value>` of the class `<class>` to the target 
SQL type `<sqlType>` in the JSON format.
 
+### FAILED_TO_PARSE_STACK_OVERFLOW
+
+[SQLSTATE: 
42907](sql-error-conditions-sqlstates.html#class-42-syntax-error-or-access-rule-violation)

Review Comment:
   ```suggestion
   [SQLSTATE: 
54001](sql-error-conditions-sqlstates.html#class-54-program-limit-exceeded)
   ```



##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -1083,6 +1083,12 @@
     ],
     "sqlState" : "42702"
   },
+  "FAILED_TO_PARSE_STACK_OVERFLOW" : {
+    "message" : [
+      "Stack overflow was hit while parsing the SQL query. "
+    ],
+    "sqlState" : "42907"

Review Comment:
   ```suggestion
       "sqlState" : "54001"
   ```



##########
docs/sql-error-conditions.md:
##########
@@ -756,6 +756,12 @@ Failed to rename temp file `<srcPath>` to `<dstPath>` as 
FileSystem.rename retur
 
 Failed to convert the row value `<value>` of the class `<class>` to the target 
SQL type `<sqlType>` in the JSON format.
 
+### FAILED_TO_PARSE_STACK_OVERFLOW

Review Comment:
   ```suggestion
   ### FAILED_TO_PARSE_STACK_TOO_COMPLEX
   ```



##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -1083,6 +1083,12 @@
     ],
     "sqlState" : "42702"
   },
+  "FAILED_TO_PARSE_STACK_OVERFLOW" : {

Review Comment:
   ```suggestion
     "FAILED_TO_PARSE_TOO_COMPLEX" : {
   ```



##########
common/utils/src/main/resources/error/error-classes.json:
##########
@@ -1083,6 +1083,12 @@
     ],
     "sqlState" : "42702"
   },
+  "FAILED_TO_PARSE_STACK_OVERFLOW" : {
+    "message" : [
+      "Stack overflow was hit while parsing the SQL query. "

Review Comment:
   ```suggestion
         "The statement, including potential SQL functions and referenced 
views,  was too complex to parse.",
         "To mitigate this error divide the statement into multiple, less 
complex chunks."
   ```



##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryParsingErrorsSuite.scala:
##########
@@ -32,6 +32,15 @@ class QueryParsingErrorsSuite extends QueryTest with 
SharedSparkSession with SQL
     intercept[ParseException](sql(sqlText).collect())
   }
 
+  test("PARSE_STACK_OVERFLOW_ERROR: Stack overflow hit") {
+    val query = (1 to 20000).map(x => "SELECT 1 as a").mkString(" UNION ALL ")
+    val e = intercept[ParseException] {
+      spark.sql(query)
+    }
+
+    assert(e.errorClass.get == "FAILED_TO_PARSE_STACK_OVERFLOW")

Review Comment:
   Use the checkError() method instead of assert.



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to