allisonwang-db commented on a change in pull request #30717:
URL: https://github.com/apache/spark/pull/30717#discussion_r542743919
##########
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 =
{
Review comment:
joinStrategyHintParameterNotSupportedError
##########
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(
Review comment:
cannotUpCastAttributeError(fromAttr: Attribute, toAttr: Attribute)
##########
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 = {
Review comment:
ditto (drop `s` in `tables`)
##########
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 = {
Review comment:
replaceColumnsOnlySupportedWithV2TableError (remove `s` in `tables`)
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryExecutionErrors.scala
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.errors
+
+import org.apache.spark.sql.catalyst.analysis.UnresolvedGenerator
+import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan}
+
+/**
+ * Object for grouping all error messages of the query runtime.
+ * Currently it includes all [[SparkException]]s and RuntimeExceptions(e.g.
+ * UnsupportedOperationException, IllegalStateException).
+ */
+object QueryExecutionErrors {
+
+ def columnChangeUnsupportedError(): Throwable = {
+ new UnsupportedOperationException("Please add an implementation for a
column change here")
+ }
+
+ def unexpectedPlanReturnError(other: LogicalPlan, methodName: String):
Throwable = {
+ new IllegalStateException(s"[BUG] unexpected plan returned by
`$methodName`: $other")
+ }
+
+ def logicalHintOperatorNotRemovedDuringAnalysisError(): Throwable = {
+ new IllegalStateException(
+ "Internal error: logical hint operator should have been removed during
analysis")
+ }
+
+ def logicalPlanHaveOutputOfCharOrVarcharError(leaf: LeafNode): Throwable = {
+ new IllegalStateException(
+ s"[BUG] logical plan should not have output of char/varchar type: $leaf")
+ }
+
+ def cannotEvaluateExpressionError(generator: UnresolvedGenerator): Throwable
= {
+ new UnsupportedOperationException(s"Cannot evaluate expression:
$generator")
+ }
+
+ def cannotGenerateCodeForExpressionError(generator: UnresolvedGenerator):
Throwable = {
+ new UnsupportedOperationException(s"Cannot generate code for expression:
$generator")
+ }
+
+ def cannotTerminateExpressionError(generator: UnresolvedGenerator):
Throwable = {
Review comment:
cannotTerminateGeneratorError
##########
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 = {
Review comment:
ditto
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -196,6 +200,11 @@ object QueryCompilationErrors {
t.origin.line, t.origin.startPosition)
}
+ def nonStreamingTempViewError(quoted: String): Throwable = {
Review comment:
readNonStreamingTempViewError
##########
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(
Review comment:
invalidFunctionArgumentNumberError
##########
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(
Review comment:
invalidHintParameterError
##########
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 = {
Review comment:
starExpandDataTypeNotSupportedError(attributes: Seq[String])
##########
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(
Review comment:
cannotResolveStarExpandGivenInputColumnsError(targetString: String,
columns: String)
##########
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 = {
Review comment:
From the comment in the code below, it seems that this error only
applies to the `COALESCE` hint. Maybe we can change it to
`invalidCoalesceHintParameterError`
##########
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 = {
Review comment:
alterQualifiedColumnOnlySupportedWithV2TableError
##########
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 = {
Review comment:
ditto (drop `s` in `tables`)
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryExecutionErrors.scala
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.errors
+
+import org.apache.spark.sql.catalyst.analysis.UnresolvedGenerator
+import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan}
+
+/**
+ * Object for grouping all error messages of the query runtime.
+ * Currently it includes all [[SparkException]]s and RuntimeExceptions(e.g.
+ * UnsupportedOperationException, IllegalStateException).
+ */
+object QueryExecutionErrors {
+
+ def columnChangeUnsupportedError(): Throwable = {
+ new UnsupportedOperationException("Please add an implementation for a
column change here")
+ }
+
+ def unexpectedPlanReturnError(other: LogicalPlan, methodName: String):
Throwable = {
+ new IllegalStateException(s"[BUG] unexpected plan returned by
`$methodName`: $other")
+ }
+
+ def logicalHintOperatorNotRemovedDuringAnalysisError(): Throwable = {
+ new IllegalStateException(
+ "Internal error: logical hint operator should have been removed during
analysis")
+ }
+
+ def logicalPlanHaveOutputOfCharOrVarcharError(leaf: LeafNode): Throwable = {
+ new IllegalStateException(
+ s"[BUG] logical plan should not have output of char/varchar type: $leaf")
+ }
+
+ def cannotEvaluateExpressionError(generator: UnresolvedGenerator): Throwable
= {
Review comment:
`cannotEvaluateGeneratorError` is probably more specific
##########
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 = {
Review comment:
ditto
##########
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 = {
Review comment:
ditto
##########
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:
ditto
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryExecutionErrors.scala
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.errors
+
+import org.apache.spark.sql.catalyst.analysis.UnresolvedGenerator
+import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan}
+
+/**
+ * Object for grouping all error messages of the query runtime.
+ * Currently it includes all [[SparkException]]s and RuntimeExceptions(e.g.
+ * UnsupportedOperationException, IllegalStateException).
+ */
+object QueryExecutionErrors {
+
+ def columnChangeUnsupportedError(): Throwable = {
+ new UnsupportedOperationException("Please add an implementation for a
column change here")
+ }
+
+ def unexpectedPlanReturnError(other: LogicalPlan, methodName: String):
Throwable = {
+ new IllegalStateException(s"[BUG] unexpected plan returned by
`$methodName`: $other")
+ }
+
+ def logicalHintOperatorNotRemovedDuringAnalysisError(): Throwable = {
+ new IllegalStateException(
+ "Internal error: logical hint operator should have been removed during
analysis")
+ }
+
+ def logicalPlanHaveOutputOfCharOrVarcharError(leaf: LeafNode): Throwable = {
+ new IllegalStateException(
+ s"[BUG] logical plan should not have output of char/varchar type: $leaf")
+ }
+
+ def cannotEvaluateExpressionError(generator: UnresolvedGenerator): Throwable
= {
+ new UnsupportedOperationException(s"Cannot evaluate expression:
$generator")
+ }
+
+ def cannotGenerateCodeForExpressionError(generator: UnresolvedGenerator):
Throwable = {
Review comment:
cannotGenerateCodeForGeneratorError
----------------------------------------------------------------
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]