urosstan-db commented on code in PR #56899:
URL: https://github.com/apache/spark/pull/56899#discussion_r3497887135


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala:
##########
@@ -259,8 +259,22 @@ private case class PostgresDialect()
   }
 
   // See https://www.postgresql.org/docs/current/errcodes-appendix.html
+  // Class 42 is "Syntax Error or Access Rule Violation", so it bundles 
genuine syntax errors
+  // together with authorization failures. 42501 is the insufficient_privilege 
state (e.g.
+  // "permission denied for table ..."), an access rule violation, not a 
syntax error. Additionally
+  // guard by message: some Postgres-compatible engines surface permission 
errors under the generic
+  // 42000 state, and access-control failures ("permission denied", "access 
denied", "unauthorized")
+  // must never be wrapped as JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR.
   override def isSyntaxErrorBestEffort(exception: SQLException): Boolean = {
-    Option(exception.getSQLState).exists(_.startsWith("42"))
+    lazy val isAccessControlError = Option(exception.getMessage)

Review Comment:
   When we get permission error, we should report table not found as well. Can 
you take a look on method `isObjectNotFoundException` and check whether we need 
to update it? 



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