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


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala:
##########
@@ -310,6 +310,56 @@ class QueryCompilationErrorsSuite extends QueryTest with 
SharedSparkSession {
       }
     }
   }
+
+  test("INVALID_OPERATION_ON_TEMP_VIEW: desc partition on a temporary view") {
+    val tableName: String = "t"
+    val tempViewName: String = "tempView"
+
+    withTable(tableName) {
+      sql(
+        s"""
+          |CREATE TABLE $tableName (a STRING, b INT, c STRING, d STRING)
+          |USING parquet
+          |PARTITIONED BY (c, d)
+          |""".stripMargin)
+
+      withTempView(tempViewName) {
+        sql(s"CREATE TEMPORARY VIEW $tempViewName as SELECT * FROM $tableName")
+
+        val e = intercept[AnalysisException](
+          sql(s"DESC TABLE $tempViewName PARTITION (c='Us', d=1)")
+        )
+        assert(e.errorClass === Some("INVALID_OPERATION_ON_TEMP_VIEW"))

Review Comment:
   nit: for consistency with other places
   ```suggestion
           assert(e.getErrorClass === "INVALID_OPERATION_ON_TEMP_VIEW")
   ```



##########
core/src/main/resources/error/error-classes.json:
##########
@@ -109,6 +109,12 @@
   "INVALID_JSON_SCHEMA_MAPTYPE" : {
     "message" : [ "Input schema %s can only contain StringType as a key type 
for a MapType." ]
   },
+  "INVALID_OPERATION_ON_TEMP_VIEW" : {
+    "message" : [ "Operation %s is not allowed on a temporary view: %s" ]
+  },
+  "INVALID_OPERATION_ON_VIEW" : {
+    "message" : [ "Operation %s is not allowed on a view: %s" ]
+  },

Review Comment:
   Don't think we should introduce two error classes for almost the same. Could 
you add only one but more generic:
   ```
     "FORBIDDEN_OPERATION" : {
       "message" : [ "The operation %s is not allowed on %s: %s" ]
     },
   ```
   Don't think we should translate values of second arg to local languages: 
"the temporary view" and "the view:".



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