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


##########
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:
   Hi @gengliangwang I looked at this at length some more, and I was able to 
reuse the existing plan `canonicalize` method after all using 
`AnalysisHelper.allowInvokingTransformsInAnalyzer` in one specific place 
instead. Now there is no need to introduce new code for this purpose. Please 
take another look.



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