You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2023/03/01 04:55:48 UTC

[spark] branch master updated: [SPARK-42337][SQL][FOLLOWUP] Update the error message for INVALID_TEMP_OBJ_REFERENCE

This is an automated email from the ASF dual-hosted git repository.

maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new de56622347e [SPARK-42337][SQL][FOLLOWUP] Update the error message for INVALID_TEMP_OBJ_REFERENCE
de56622347e is described below

commit de56622347e0cd3be17442e472aee0c13f8551f3
Author: allisonwang-db <al...@databricks.com>
AuthorDate: Wed Mar 1 07:55:02 2023 +0300

    [SPARK-42337][SQL][FOLLOWUP] Update the error message for INVALID_TEMP_OBJ_REFERENCE
    
    ### What changes were proposed in this pull request?
    
    This PR is a follow-up for #39910. It updates the error message of the error class INVALID_TEMP_OBJ_REFERENCE.
    
    ### Why are the changes needed?
    
    To make the error message more user-friendly.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. This PR updates the error message for INVALID_TEMP_OBJ_REFERENCE.
    
    ### How was this patch tested?
    
    Existing tests
    
    Closes #40198 from allisonwang-db/spark-42337-follow-up.
    
    Authored-by: allisonwang-db <al...@databricks.com>
    Signed-off-by: Max Gekk <ma...@gmail.com>
---
 core/src/main/resources/error/error-classes.json   |  2 +-
 .../spark/sql/errors/QueryCompilationErrors.scala  |  8 ++--
 .../results/postgreSQL/create_view.sql.out         | 52 +++++++++++-----------
 .../scala/org/apache/spark/sql/SQLQuerySuite.scala |  8 ++--
 .../spark/sql/connector/DataSourceV2SQLSuite.scala |  4 +-
 .../apache/spark/sql/execution/SQLViewSuite.scala  |  8 ++--
 .../spark/sql/execution/SQLViewTestSuite.scala     |  8 ++--
 .../sql/hive/execution/HiveSQLViewSuite.scala      |  4 +-
 8 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json
index 408c97acaa3..3dba15c6584 100644
--- a/core/src/main/resources/error/error-classes.json
+++ b/core/src/main/resources/error/error-classes.json
@@ -1041,7 +1041,7 @@
   },
   "INVALID_TEMP_OBJ_REFERENCE" : {
     "message" : [
-      "Cannot create a persistent <obj> <objName> by referencing a temporary <tempObj> <tempObjName>. Please make the temporary <tempObj> persistent, or make the persistent <obj> temporary."
+      "Cannot create the persistent object <objName> of the type <obj> because it references to the temporary object <tempObjName> of the type <tempObj>. Please make the temporary object <tempObjName> persistent, or make the persistent object <objName> temporary."
     ]
   },
   "INVALID_TYPED_LITERAL" : {
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
index 1c257966aaf..e4475980cf9 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
@@ -2692,9 +2692,9 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase {
     new AnalysisException(
       errorClass = "INVALID_TEMP_OBJ_REFERENCE",
       messageParameters = Map(
-        "obj" -> "view",
+        "obj" -> "VIEW",
         "objName" -> toSQLId(name.nameParts),
-        "tempObj" -> "view",
+        "tempObj" -> "VIEW",
         "tempObjName" -> toSQLId(nameParts)))
   }
 
@@ -2704,9 +2704,9 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase {
      new AnalysisException(
       errorClass = "INVALID_TEMP_OBJ_REFERENCE",
       messageParameters = Map(
-        "obj" -> "view",
+        "obj" -> "VIEW",
         "objName" -> toSQLId(name.nameParts),
-        "tempObj" -> "function",
+        "tempObj" -> "FUNCTION",
         "tempObjName" -> toSQLId(funcName)))
   }
 
diff --git a/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out b/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out
index 2768f7b53b4..59e574c27e3 100644
--- a/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out
@@ -280,9 +280,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v1_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -344,9 +344,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v3_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -401,9 +401,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v4_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -421,9 +421,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v5_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -588,9 +588,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v6_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -605,9 +605,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v7_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -622,9 +622,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v8_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -639,9 +639,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`temp_view_test`.`v9_temp`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`temp_table`"
   }
 }
@@ -795,9 +795,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`testviewschm2`.`temporal1`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`tt`"
   }
 }
@@ -844,9 +844,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`testviewschm2`.`temporal2`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`tt`"
   }
 }
@@ -893,9 +893,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`testviewschm2`.`temporal3`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`tt`"
   }
 }
@@ -942,9 +942,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`testviewschm2`.`temporal4`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`tt`"
   }
 }
@@ -959,9 +959,9 @@ org.apache.spark.sql.AnalysisException
 {
   "errorClass" : "INVALID_TEMP_OBJ_REFERENCE",
   "messageParameters" : {
-    "obj" : "view",
+    "obj" : "VIEW",
     "objName" : "`spark_catalog`.`testviewschm2`.`temporal5`",
-    "tempObj" : "view",
+    "tempObj" : "VIEW",
     "tempObjName" : "`tt`"
   }
 }
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
index 377be2e720a..123364f18ce 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
@@ -3972,9 +3972,9 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
           exception = e,
           errorClass = "INVALID_TEMP_OBJ_REFERENCE",
           parameters = Map(
-            "obj" -> "view",
+            "obj" -> "VIEW",
             "objName" -> s"`$SESSION_CATALOG_NAME`.`default`.`$testViewName`",
-            "tempObj" -> "view",
+            "tempObj" -> "VIEW",
             "tempObjName" -> s"`$tempViewName`"))
 
         val e2 = intercept[AnalysisException] {
@@ -3991,9 +3991,9 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
           exception = e2,
           errorClass = "INVALID_TEMP_OBJ_REFERENCE",
           parameters = Map(
-            "obj" -> "view",
+            "obj" -> "VIEW",
             "objName" -> s"`$SESSION_CATALOG_NAME`.`default`.`$testViewName`",
-            "tempObj" -> "function",
+            "tempObj" -> "FUNCTION",
             "tempObjName" -> s"`$tempFuncName`"))
       }
     }
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
index 85984f1b2a8..122e3bdd854 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
@@ -2408,9 +2408,9 @@ class DataSourceV2SQLSuiteV1Filter
           },
           errorClass = "INVALID_TEMP_OBJ_REFERENCE",
           parameters = Map(
-            "obj" -> "view",
+            "obj" -> "VIEW",
             "objName" -> "`spark_catalog`.`default`.`v`",
-            "tempObj" -> "view",
+            "tempObj" -> "VIEW",
             "tempObjName" -> "`t`"))
       }
     }
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
index 26b0e765700..8cb91d3b754 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
@@ -87,9 +87,9 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
             },
             errorClass = "INVALID_TEMP_OBJ_REFERENCE",
             parameters = Map(
-              "obj" -> "view",
+              "obj" -> "VIEW",
               "objName" -> s"`$SESSION_CATALOG_NAME`.`default`.`jtv1`",
-              "tempObj" -> "view",
+              "tempObj" -> "VIEW",
               "tempObjName" -> "`temp_jtv1`"))
           val globalTempDB = spark.sharedState.globalTempViewManager.database
           sql("CREATE GLOBAL TEMP VIEW global_temp_jtv1 AS SELECT * FROM jt WHERE id > 0")
@@ -99,9 +99,9 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
             },
             errorClass = "INVALID_TEMP_OBJ_REFERENCE",
             parameters = Map(
-              "obj" -> "view",
+              "obj" -> "VIEW",
               "objName" -> s"`$SESSION_CATALOG_NAME`.`default`.`jtv1`",
-              "tempObj" -> "view",
+              "tempObj" -> "VIEW",
               "tempObjName" -> "`global_temp`.`global_temp_jtv1`"))
         }
       }
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
index 34dfdf12357..4e89d6fdf5e 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
@@ -616,9 +616,9 @@ class PersistedViewTestSuite extends SQLViewTestSuite with SharedSparkSession {
             },
             errorClass = "INVALID_TEMP_OBJ_REFERENCE",
             parameters = Map(
-              "obj" -> "view",
+              "obj" -> "VIEW",
               "objName" -> s"`$SESSION_CATALOG_NAME`.`default`.`v1`",
-              "tempObj" -> "view",
+              "tempObj" -> "VIEW",
               "tempObjName" -> "`v2`"))
           val tempFunctionName = "temp_udf"
           val functionClass = "test.org.apache.spark.sql.MyDoubleAvg"
@@ -630,9 +630,9 @@ class PersistedViewTestSuite extends SQLViewTestSuite with SharedSparkSession {
               },
               errorClass = "INVALID_TEMP_OBJ_REFERENCE",
               parameters = Map(
-                "obj" -> "view",
+                "obj" -> "VIEW",
                 "objName" -> s"`$SESSION_CATALOG_NAME`.`default`.`v1`",
-                "tempObj" -> "function",
+                "tempObj" -> "FUNCTION",
                 "tempObjName" -> s"`$tempFunctionName`"))
           }
         }
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveSQLViewSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveSQLViewSuite.scala
index bf4954eeb1e..8b7f7ade560 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveSQLViewSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveSQLViewSuite.scala
@@ -88,9 +88,9 @@ class HiveSQLViewSuite extends SQLViewSuite with TestHiveSingleton {
               exception = e,
               errorClass = "INVALID_TEMP_OBJ_REFERENCE",
               parameters = Map(
-                "obj" -> "view",
+                "obj" -> "VIEW",
                 "objName" -> s"`$SESSION_CATALOG_NAME`.`default`.`view1`",
-                "tempObj" -> "function",
+                "tempObj" -> "FUNCTION",
                 "tempObjName" -> s"`$tempFunctionName`"))
           }
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org