srielau commented on code in PR #37887:
URL: https://github.com/apache/spark/pull/37887#discussion_r990229253
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/AlreadyExistException.scala:
##########
@@ -20,72 +20,105 @@ package org.apache.spark.sql.catalyst.analysis
import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.catalog.CatalogTypes.TablePartitionSpec
-import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
-import org.apache.spark.sql.connector.catalog.Identifier
+import org.apache.spark.sql.catalyst.util.{quoteIdentifier, quoteNameParts }
import org.apache.spark.sql.types.StructType
/**
* Thrown by a catalog when an item already exists. The analyzer will rethrow
the exception
* as an [[org.apache.spark.sql.AnalysisException]] with the correct position
information.
*/
class DatabaseAlreadyExistsException(db: String)
- extends NamespaceAlreadyExistsException(s"Database '$db' already exists")
+ extends NamespaceAlreadyExistsException(Array(db))
-class NamespaceAlreadyExistsException(message: String)
- extends AnalysisException(
- message,
- errorClass = Some("_LEGACY_ERROR_TEMP_1118"),
- messageParameters = Map("msg" -> message)) {
+
+class NamespaceAlreadyExistsException(errorClass: String, messageParameters:
Map[String, String])
+ extends AnalysisException(errorClass, messageParameters) {
def this(namespace: Array[String]) = {
- this(s"Namespace '${namespace.quoted}' already exists")
+ this(errorClass = "SCHEMA_ALREADY_EXISTS",
+ Map("schemaName" -> quoteNameParts(namespace)))
}
}
-class TableAlreadyExistsException(message: String, cause: Option[Throwable] =
None)
- extends AnalysisException(
- message,
- errorClass = Some("_LEGACY_ERROR_TEMP_1116"),
- messageParameters = Map("msg" -> message),
- cause = cause) {
+
+class TableAlreadyExistsException(errorClass: String, messageParameters:
Map[String, String],
+ cause: Option[Throwable] = None)
+ extends AnalysisException(errorClass, messageParameters, cause = cause) {
def this(db: String, table: String) = {
- this(s"Table or view '$table' already exists in database '$db'")
+ this(errorClass = "TABLE_OR_VIEW_ALREADY_EXISTS",
+ messageParameters = Map("relationName" ->
+ (quoteIdentifier(db) + "." + quoteIdentifier(table))))
Review Comment:
I'm not aware of one. If you point me I can use it. At a minimum I'd have to
build a sequence first. Just to unravel 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]