beliefer commented on a change in pull request #30717:
URL: https://github.com/apache/spark/pull/30717#discussion_r543004865



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -326,4 +340,164 @@ object QueryCompilationErrors {
       "of rows, therefore they are currently not supported.", t.origin.line, 
t.origin.startPosition)
   }
 
+  def viewOutputNumberMismatchQueryColumnNamesError(
+      output: Seq[Attribute], queryColumnNames: Seq[String]): Throwable = {
+    new AnalysisException(
+      s"The view output ${output.mkString("[", ",", "]")} doesn't have the 
same" +
+        "number of columns with the query column names " +
+        s"${queryColumnNames.mkString("[", ",", "]")}")
+  }
+
+  def attributeNotFoundError(colName: String, child: LogicalPlan): Throwable = 
{
+    new AnalysisException(
+      s"Attribute with name '$colName' is not found in " +
+        s"'${child.output.map(_.name).mkString("(", ",", ")")}'")
+  }
+
+  def cannotUpCastAsAttributeTruncateError(
+      originAttr: Attribute, catalogString: String): Throwable = {
+    new AnalysisException(s"Cannot up cast ${originAttr.sql} from " +
+      s"${originAttr.dataType.catalogString} to $catalogString as it may 
truncate\n")
+  }
+
+  def functionUndefinedError(name: FunctionIdentifier): Throwable = {
+    new AnalysisException(s"undefined function $name")
+  }
+
+  def invalidFunctionArgumentsError(
+      validParametersCount: Seq[Int], name: String, params: 
Seq[Class[Expression]]): Throwable = {
+    val invalidArgumentsMsg = if (validParametersCount.length == 0) {
+      s"Invalid arguments for function $name"
+    } else {
+      val expectedNumberOfParameters = if (validParametersCount.length == 1) {
+        validParametersCount.head.toString
+      } else {
+        validParametersCount.init.mkString("one of ", ", ", " and ") +
+          validParametersCount.last
+      }
+      s"Invalid number of arguments for function $name. " +
+        s"Expected: $expectedNumberOfParameters; Found: ${params.length}"
+    }
+    new AnalysisException(invalidArgumentsMsg)
+  }
+
+  def functionAcceptsOnlyOneArgumentError(name: String): Throwable = {
+    new AnalysisException(s"Function $name accepts only one argument")
+  }
+
+  def alterV2TableSetLocationWithPartitionNotSupportedError(): Throwable = {
+    new AnalysisException("ALTER TABLE SET LOCATION does not support partition 
for v2 tables.")
+  }
+
+  def joinStrategyHintParameterNotExpectedError(unsupported: Any): Throwable = 
{
+    new AnalysisException("Join strategy hint parameter " +
+      s"should be an identifier or string but was $unsupported 
(${unsupported.getClass}")
+  }
+
+  def hintParameterNotIncludeColumnsError(
+      hintName: String, invalidParams: Seq[Any]): Throwable = {
+    new AnalysisException(s"$hintName Hint parameter should include columns, 
but " +
+      s"${invalidParams.mkString(", ")} found")
+  }
+
+  def hintParameterNotExpectedError(hintName: String): Throwable = {
+    new AnalysisException(s"$hintName Hint expects a partition number as a 
parameter")
+  }
+
+  def attributeNameSyntaxError(name: String): Throwable = {
+    new AnalysisException(s"syntax error in attribute name: $name")
+  }
+
+  def onlyStarExpandStructDataTypesError(target: Option[Seq[String]]): 
Throwable = {
+    new AnalysisException(s"Can only star expand struct data types. Attribute: 
`${target.get}`")
+  }
+
+  def cannotResolveTargetAccordingGivenInputColumnsError(
+      targetString: String, from: String): Throwable = {
+    new AnalysisException(s"cannot resolve '$targetString.*' given input 
columns '$from'")
+  }
+
+  def addColumnWithV1TableCannotSpecifyNotNullError(): Throwable = {
+    new AnalysisException("ADD COLUMN with v1 tables cannot specify NOT NULL.")
+  }
+
+  def replaceColumnsOnlySupportedWithV2TablesError(): Throwable = {
+    new AnalysisException("REPLACE COLUMNS is only supported with v2 tables.")
+  }
+
+  def alterQualifiedColumnOnlySupportedWithV2TablesError(): Throwable = {
+    new AnalysisException("ALTER COLUMN with qualified column is only 
supported with v2 tables.")
+  }
+
+  def alterColumnWithV1TablesCannotSpecifyNotNullError(): Throwable = {
+    new AnalysisException("ALTER COLUMN with v1 tables cannot specify NOT 
NULL.")
+  }
+
+  def alterOnlySupportedWithV2TablesError(): Throwable = {
+    new AnalysisException("ALTER COLUMN ... FIRST | ALTER is only supported 
with v2 tables.")
+  }
+
+  def alterColumnCannotFindColumnInV1TableError(colName: String, v1Table: 
V1Table): Throwable = {
+    new AnalysisException(
+      s"ALTER COLUMN cannot find column $colName in v1 table. " +
+        s"Available: ${v1Table.schema.fieldNames.mkString(", ")}")
+  }
+
+  def renameColumnOnlySupportedWithV2TablesError(): Throwable = {
+    new AnalysisException("RENAME COLUMN is only supported with v2 tables.")
+  }
+
+  def dropColumnOnlySupportedWithV2TablesError(): Throwable = {
+    new AnalysisException("DROP COLUMN is only supported with v2 tables.")
+  }
+
+  def invalidDatabaseNameError(quoted: String): Throwable = {
+    new AnalysisException(s"The database name is not valid: $quoted")
+  }
+
+  def replaceTableOnlySupportedWithV2TablesError(): Throwable = {
+    new AnalysisException("REPLACE TABLE is only supported with v2 tables.")
+  }
+
+  def replaceTableAsSelectOnlySupportedWithV2TablesError(): Throwable = {

Review comment:
       OK




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

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