dgd-contributor commented on a change in pull request #32951:
URL: https://github.com/apache/spark/pull/32951#discussion_r661942662



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
##########
@@ -1694,4 +1697,355 @@ private[spark] object QueryCompilationErrors {
     new AnalysisException(
       s"Found duplicate column(s) $colType: ${duplicateCol.sorted.mkString(", 
")}")
   }
+
+  def noSuchTableError(db: String, table: String): Throwable = {
+    new NoSuchTableException(db = db, table = table)
+  }
+
+  def tempViewNotCachedForAnalyzingColError(tableIdent: TableIdentifier): 
Throwable = {
+    new AnalysisException(s"Temporary view $tableIdent is not cached for 
analyzing columns.")
+  }
+
+  def colNotExistError(col: String): Throwable = {
+    new AnalysisException(s"Column $col does not exist.")
+  }
+
+  def colTypeNotSupportStatisticsCollectionError(
+      name: String,
+      tableIdent: TableIdentifier,
+      dataType: DataType): Throwable = {
+    new AnalysisException(s"Column $name in table $tableIdent is of type 
$dataType, " +
+      "and Spark does not support statistics collection on this column type.")
+  }
+
+  def analyzeTableNotSupportedOnViewsError(): Throwable = {
+    new AnalysisException("ANALYZE TABLE is not supported on views.")
+  }
+
+  def notGetExpectedPrefixColError(
+      table: String,
+      database: String,
+      schemaColumns: String,
+      specColumns: String): Throwable = {
+    new AnalysisException("The list of partition columns with values " +
+      s"in partition specification for table '${table}' " +
+      s"in database '${database}' is not a prefix of the list of " +
+      "partition columns defined in the table schema. " +
+      s"Expected a prefix of [${schemaColumns}], but got [${specColumns}].")
+  }
+
+  def noSuchPartitionError(
+      db: String,
+      table: String,
+      partition: TablePartitionSpec): Throwable = {
+    new NoSuchPartitionException(db, table, partition)
+  }
+
+  def analyzingColStatisticsNotSupportedOfDataTypeError(
+      name: String,
+      dataType: DataType): Throwable = {
+    new AnalysisException("Analyzing column statistics is not supported for 
column " +
+      s"$name of data type: $dataType.")
+  }
+
+  def tableAlreadyExistsError(table: String, guide: String): Throwable = {
+    new AnalysisException(s"Table $table already exists." + guide)
+  }
+
+  def createTableAsSelectCanNotCreateTableOnNonEmptyDirError(tablePath: 
String): Throwable = {
+    new AnalysisException(
+      s"CREATE-TABLE-AS-SELECT cannot create table with location to a 
non-empty directory " +
+        s"${tablePath} . To allow overwriting the existing non-empty 
directory, " +
+        s"set '${SQLConf.ALLOW_NON_EMPTY_LOCATION_IN_CTAS.key}' to true.")
+  }
+
+  def tableOrViewNotFoundError(table: String): Throwable = {
+    new AnalysisException(s"Table or view not found: $table")
+  }
+
+  def unsetNonExistentPropertyError(property: String, table: TableIdentifier): 
Throwable = {
+    new AnalysisException(s"Attempted to unset non-existent property 
'$property' in table '$table'")
+  }
+
+  def alterTableChangeColumnNotSupportForTypeError(
+      originColumn: StructField,
+      newColumn: StructField): Throwable = {
+    new AnalysisException("ALTER TABLE CHANGE COLUMN is not supported for 
changing column " +
+      s"'${originColumn.name}' with type '${originColumn.dataType}' to " +
+      s"'${newColumn.name}' with type '${newColumn.dataType}'")
+  }
+
+  def cannotFindColumnError(name: String, fieldNames: Array[String]): 
Throwable = {
+    new AnalysisException(s"Can't find column `$name` given table data columns 
" +
+      s"${fieldNames.mkString("[`", "`, `", "`]")}")
+  }
+
+  def alterTableSetSerdeForSpecificPartitionNotSupportedError(): Throwable = {
+    new AnalysisException("Operation not allowed: ALTER TABLE SET " +
+      "[SERDE | SERDEPROPERTIES] for a specific partition is not supported " +
+      "for tables created with the datasource API")
+  }
+
+  def alterTableSetSerdeNotSupportedError(): Throwable = {
+    new AnalysisException("Operation not allowed: ALTER TABLE SET SERDE is " +
+      "not supported for tables created with the datasource API")
+  }
+
+  def cmdOnlyWorksOnPartitionedTables(cmd: String, tableIdentWithDB: String): 
Throwable = {
+    new AnalysisException(
+      s"Operation not allowed: $cmd only works on partitioned tables: 
$tableIdentWithDB")
+  }
+
+  def cmdOnlyWorksOnTables(cmd: String, tableIdentWithDB: String): Throwable = 
{
+    new AnalysisException(s"Operation not allowed: $cmd only works on table 
with " +
+      s"location provided: $tableIdentWithDB")
+  }
+
+  def actionNotAllowedOnTableSinceFilesourcePartitionManagementDisableError(
+      action: String,
+      tableName: String): Throwable = {
+    new AnalysisException(
+      s"$action is not allowed on $tableName since filesource partition 
management is " +
+        "disabled (spark.sql.hive.manageFilesourcePartitions = false).")
+  }
+
+  def actionNotAllowedOnTableSincePartitionMetadataNotStoredError(
+     action: String,
+     tableName: String): Throwable = {
+    new AnalysisException(
+      s"$action is not allowed on $tableName since its partition metadata is 
not stored in " +
+        "the Hive metastore. To import this information into the metastore, 
run " +
+        s"`msck repair table $tableName`")
+  }
+
+  def cannotAlterViewWithAlterTableError(): Throwable = {
+    new AnalysisException(
+      "Cannot alter a view with ALTER TABLE. Please use ALTER VIEW instead")
+  }
+
+  def cannotAlterTableWithAlterViewError(): Throwable = {
+    new AnalysisException(
+      "Cannot alter a table with ALTER VIEW. Please use ALTER TABLE instead")
+  }
+
+  def cannotOverwritePathIsReadError(): Throwable = {
+    new AnalysisException("Cannot overwrite a path that is also being read 
from.")
+  }
+
+  def createFuncWithBothIfNotExistsAndReplaceError(): Throwable = {
+    new AnalysisException("CREATE FUNCTION with both IF NOT EXISTS and REPLACE 
is not allowed.")
+  }
+
+  def defineTempFuncWithIfExistsError(): Throwable = {
+    new AnalysisException("It is not allowed to define a TEMPORARY function 
with IF NOT EXISTS.")
+  }
+
+  def specifyingDBInCreateTempFuncError(databaseName: String): Throwable = {
+    new AnalysisException(
+      s"Specifying a database in CREATE TEMPORARY FUNCTION is not allowed: 
'$databaseName'")
+  }
+
+  def specifyingDBInDropTempFuncError(databaseName: String): Throwable = {
+    new AnalysisException(
+      s"Specifying a database in DROP TEMPORARY FUNCTION is not allowed: 
'$databaseName'")
+  }
+
+  def cannotDropNativeFuncError(functionName: String): Throwable = {
+    new AnalysisException(s"Cannot drop native function '$functionName'")
+  }
+
+  def cannotRefreshBuiltInFuncError(functionName: String): Throwable = {
+    new AnalysisException(s"Cannot refresh built-in function $functionName")
+  }
+
+  def cannotRefreshTempFuncError(functionName: String): Throwable = {
+    new AnalysisException(s"Cannot refresh temporary function $functionName")
+  }
+
+  def noSuchFunctionError(identifier: FunctionIdentifier): Throwable = {
+    new NoSuchFunctionException(identifier.database.get, identifier.funcName)
+  }
+
+  def alterAddColNotSupportViewError(table: TableIdentifier): Throwable = {
+    new AnalysisException(s"""
+         ALTER ADD COLUMNS does not support views.
+         You must drop and re-create the views for adding the new columns. 
Views: $table
+         """)
+  }
+
+  def alterAddColNotSupportDatasourceTableError(
+      tableType: Any,
+      table: TableIdentifier): Throwable = {
+    new AnalysisException(s"""
+         ALTER ADD COLUMNS does not support datasource table with type 
$tableType.
+         You must drop and re-create the table for adding the new columns. 
Tables: $table
+         """)
+  }
+
+  def loadDataNotSupportedForDatasourceTablesError(tableIdentWithDB: String): 
Throwable = {
+    new AnalysisException(s"LOAD DATA is not supported for datasource tables: 
$tableIdentWithDB")
+  }
+
+  def loadDataNoPartitionSpecProvidedError(tableIdentWithDB: String): 
Throwable = {
+    new AnalysisException(s"LOAD DATA target table $tableIdentWithDB is 
partitioned, " +
+      s"but no partition spec is provided")
+  }
+
+  def loadDataNumberColsNotMatchError(
+      tableIdentWithDB: String,
+      partitionSize: Int,
+      targetTableSize: Int): Throwable = {
+    new AnalysisException(s"LOAD DATA target table $tableIdentWithDB is 
partitioned, " +
+      s"but number of columns in provided partition spec ($partitionSize) " +
+      s"do not match number of partitioned columns in table " +
+      s"($targetTableSize)")
+  }
+
+  def loadDataButPartitionSpecWasProvidedError(tableIdentWithDB: String): 
Throwable = {
+    new AnalysisException(s"LOAD DATA target table $tableIdentWithDB is not " +
+      s"partitioned, but a partition spec was provided.")
+  }
+
+  def loadDataInputPathNotExistError(path: String): Throwable = {
+    new AnalysisException(s"LOAD DATA input path does not exist: $path")
+  }
+
+  def truncateTableOnExternalTablesError(tableIdentWithDB: String): Throwable 
= {
+    new AnalysisException(
+      s"Operation not allowed: TRUNCATE TABLE on external tables: 
$tableIdentWithDB")
+  }
+
+  def truncateTablePartitionNotSupportedOnTableNotPartitionedError(
+      tableIdentWithDB: String): Throwable = {
+    new AnalysisException(s"Operation not allowed: TRUNCATE TABLE ... 
PARTITION is not supported" +
+      s" for tables that are not partitioned: $tableIdentWithDB")
+  }
+
+  def failToTruncateTableWhenRemovingDataError(
+      tableIdentWithDB: String,
+      path: Path,
+      e: Throwable): Throwable = {
+    new AnalysisException(s"Failed to truncate table $tableIdentWithDB when " +
+        s"removing data of the path: $path because of ${e.toString}")
+  }
+
+  def descPartitionNotAllowedOnTempView(table: String): Throwable = {
+    new AnalysisException(s"DESC PARTITION is not allowed on a temporary view: 
$table")
+  }
+
+  def descPartitionNotAllowedOnView(table: String): Throwable = {
+    new AnalysisException(s"DESC PARTITION is not allowed on a view: $table")
+  }
+
+  def showPartitionNotAllowedOnTableNotPartitionedError(tableIdentWithDB: 
String): Throwable = {
+    new AnalysisException(
+      s"SHOW PARTITIONS is not allowed on a table that is not partitioned: 
$tableIdentWithDB")
+  }
+
+  def showCreateTableNotSupportedOnTempView(table: String): Throwable = {
+    new AnalysisException(s"SHOW CREATE TABLE is not supported on a temporary 
view: $table")
+  }
+
+  def showCreateTableFailToExecuteUnsupportedFeatureError(table: 
CatalogTable): Throwable = {
+    new AnalysisException("Failed to execute SHOW CREATE TABLE against table " 
+

Review comment:
       how can we use stripMargin.replace("\n", " ") here, since there are "\n" 
in this message?




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