dtenedor commented on code in PR #37840:
URL: https://github.com/apache/spark/pull/37840#discussion_r972488615


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/package.scala:
##########
@@ -45,18 +51,101 @@ package object analysis {
       throw new AnalysisException(msg, t.origin.line, t.origin.startPosition)
     }
 
-    /** Fails the analysis at the point where a specific tree node was parsed. 
*/
+    /** Fails the analysis at the point where a specific tree node was parsed 
with a given cause. */
     def failAnalysis(msg: String, cause: Throwable): Nothing = {
       throw new AnalysisException(msg, t.origin.line, t.origin.startPosition, 
cause = Some(cause))
     }
 
+    /**
+     * Fails the analysis at the point where a specific tree node was parsed 
using a provided
+     * error class and message parameters.
+     */
     def failAnalysis(errorClass: String, messageParameters: Map[String, 
String]): Nothing = {
       throw new AnalysisException(
         errorClass = errorClass,
         messageParameters = messageParameters,
         origin = t.origin)
     }
 
+    /**
+     * Fails the analysis at the point where a specific tree node was parsed 
using a provided
+     * error class and subclass and message parameters.
+     */
+    def failAnalysis(
+        errorClass: String,
+        errorSubClass: String,
+        messageParameters: Map[String, String] = Map.empty[String, String]): 
Nothing = {
+      throw new AnalysisException(
+        errorClass = errorClass,
+        errorSubClass = errorSubClass,
+        messageParameters = messageParameters,
+        origin = t.origin)
+    }
+
+    /**
+     * Fails the analysis at the point where a specific tree node was parsed 
using a provided
+     * error class and subclass and one message parameter comprising a plan 
string. The plan string
+     * will be printed in the error message if and only if the corresponding 
Spark configuration is
+     * enabled.
+     */
+    def failAnalysis(
+        errorClass: String,
+        errorSubClass: String,
+        treeNodes: Seq[TreeNode[_]]): Nothing = {
+      // Normalize expression IDs in the query plan to keep tests 
deterministic.

Review Comment:
   I tried this, but this `canonicalized` method is not available during 
analysis since it uses `transformUp`, triggering this error:
   ```
   def methodCalledInAnalyzerNotAllowedError(): Throwable = {
     new RuntimeException("This method should not be called in the analyzer")
   }
   ```
   Therefore a separate implementation is needed.



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