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


##########
sql/core/src/test/resources/sql-tests/results/udf/udf-except.sql.out:
##########
@@ -100,12 +100,17 @@ WHERE  udf(t1.v) >= (SELECT   min(udf(t2.v))
 struct<>
 -- !query output
 org.apache.spark.sql.AnalysisException
-Correlated column is not allowed in predicate (CAST(udf(cast(k as string)) AS 
STRING) = CAST(udf(cast(outer(k#x) as string)) AS STRING)):
-Aggregate [cast(udf(cast(max(cast(udf(cast(v#x as string)) as int)) as 
string)) as int) AS udf(max(udf(v)))#x]
-+- Filter (cast(udf(cast(k#x as string)) as string) = cast(udf(cast(outer(k#x) 
as string)) as string))
-   +- SubqueryAlias t2
-      +- View (`t2`, [k#x,v#x])
-         +- Project [cast(k#x as string) AS k#x, cast(v#x as int) AS v#x]
-            +- Project [k#x, v#x]
-               +- SubqueryAlias t2
-                  +- LocalRelation [k#x, v#x]
+{
+  "errorClass" : "UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY",
+  "errorSubClass" : "CORRELATED_COLUMN_IS_NOT_ALLOWED_IN_PREDICATE",
+  "messageParameters" : {
+    "planString" : ": (cast(udf(cast(k#0 as string)) as string) = 
cast(udf(cast(outer(k#1) as string)) as string))"

Review Comment:
   Is it a plan string? Let's rename it.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala:
##########
@@ -1563,10 +1563,12 @@ private[sql] object QueryCompilationErrors extends 
QueryErrorsBase {
     new AnalysisException(s"'$operation' does not support partitioning")
   }
 
-  def mixedRefsInAggFunc(funcStr: String): Throwable = {
-    val msg = "Found an aggregate function in a correlated predicate that has 
both " +
-      "outer and local references, which is not supported: " + funcStr
-    new AnalysisException(msg)
+  def mixedRefsInAggFunc(funcStr: String, origin: Origin): Throwable = {
+    new AnalysisException(
+      errorClass = "UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY",
+      errorSubClass = "AGGREGATE_FUNCTION_MIXED_OUTER_LOCAL_REFERENCES",
+      origin = origin,
+      messageParameters = Map("function" -> funcStr))

Review Comment:
   Should we quote the function? by `toSQLExpr` if it is an expression or maybe 
by `toSQLId`? cc @srielau 



##########
sql/core/src/test/resources/sql-tests/results/subquery/negative-cases/invalid-correlation.sql.out:
##########
@@ -105,14 +131,20 @@ WHERE  t1a IN (SELECT t2a
 struct<>
 -- !query output
 org.apache.spark.sql.AnalysisException
-Expressions referencing the outer query are not supported outside of 
WHERE/HAVING clauses:
-Aggregate [min(outer(t2a#x)) AS min(outer(t2.t2a))#x]
-+- SubqueryAlias t3
-   +- View (`t3`, [t3a#x,t3b#x,t3c#x])
-      +- Project [cast(t3a#x as int) AS t3a#x, cast(t3b#x as int) AS t3b#x, 
cast(t3c#x as int) AS t3c#x]
-         +- Project [t3a#x, t3b#x, t3c#x]
-            +- SubqueryAlias t3
-               +- LocalRelation [t3a#x, t3b#x, t3c#x]
+{
+  "errorClass" : "UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY",
+  "errorSubClass" : "UNSUPPORTED_CORRELATED_REFERENCE",
+  "messageParameters" : {
+    "planString" : ": Aggregate [min(outer(t2a#6)) AS 
min(outer(t2.t2a))#7]\n+- SubqueryAlias t3\n   +- View (`t3`, 
[t3a#3,t3b#4,t3c#5])\n      +- Project [cast(t3a#0 as int) AS t3a#3, cast(t3b#1 
as int) AS t3b#4, cast(t3c#2 as int) AS t3c#5]\n         +- Project [t3a#0, 
t3b#1, t3c#2]\n            +- SubqueryAlias t3\n               +- LocalRelation 
[t3a#0, t3b#1, t3c#2]\n"

Review Comment:
   > t2a#6
   
   Are the IDs stable? Should we replace them like
   
https://github.com/apache/spark/blob/db5aea60e4b22449d529f9e866366cfdc784b140/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestHelper.scala#L94
   



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