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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryExecutionErrors.scala
##########
@@ -51,18 +58,209 @@ object QueryExecutionErrors {
       s"[BUG] logical plan should not have output of char/varchar type: $leaf")
   }
 
-  def cannotEvaluateGeneratorError(generator: UnresolvedGenerator): Throwable 
= {
-    new UnsupportedOperationException(s"Cannot evaluate expression: 
$generator")
+  def cannotEvaluateExpressionError(expression: Expression): Throwable = {
+    new UnsupportedOperationException(s"Cannot evaluate expression: 
$expression")
   }
 
-  def cannotGenerateCodeForGeneratorError(generator: UnresolvedGenerator): 
Throwable = {
-    new UnsupportedOperationException(s"Cannot generate code for expression: 
$generator")
+  def cannotGenerateCodeForExpressionError(expression: Expression): Throwable 
= {
+    new UnsupportedOperationException(s"Cannot generate code for expression: 
$expression")
   }
 
   def cannotTerminateGeneratorError(generator: UnresolvedGenerator): Throwable 
= {
     new UnsupportedOperationException(s"Cannot terminate expression: 
$generator")
   }
 
+  def castDownLongCauseOverflowError(t: Any, targetType: String): Throwable = {
+    new ArithmeticException(s"Casting $t to $targetType causes overflow")
+  }
+
+  def cannotRepresentDecimalError(value: Decimal, decimalType: DecimalType): 
Throwable = {
+    new ArithmeticException(s"${value.toDebugString} cannot be represented as 
" +
+      s"Decimal(${decimalType.precision}, ${decimalType.scale}).")
+  }
+
+  def invalidInputSyntaxError(s: UTF8String): Throwable = {
+    new NumberFormatException(s"invalid input syntax for type numeric: $s")
+  }
+
+  def cannotCastFromNullTypeDirectlyError(to: DataType): Throwable = {
+    new SparkException(s"should not directly cast from NullType to $to.")
+  }
+
+  def cannotCastError(from: DataType, to: DataType): Throwable = {
+    new SparkException(s"Cannot cast $from to $to.")
+  }
+
+  def cannotParseDecimalError(): Throwable = {
+    new IllegalArgumentException("Cannot parse any decimal")
+  }
+
+  def simpleStringWithNodeIdUnsupportedError(nodeName: String): Throwable = {
+    new UnsupportedOperationException(s"$nodeName does not implement 
simpleStringWithNodeId")
+  }
+
+  def evaluateUnevaluableAggregateUnsupportedError(
+      methodName: String, unEvaluable: UnevaluableAggregate): Throwable = {
+    new UnsupportedOperationException(s"Cannot evaluate $methodName: 
$unEvaluable")
+  }
+
+  def dataTypeUnsupportedError(dt: DataType): Throwable = {
+    new SparkException(s"Unsupported data type $dt")
+  }
+
+  def udfErrorMessage(funcCls: String, inputTypes: String, outputType: 
String): String = {
+    s"Failed to execute user defined function ($funcCls: ($inputTypes) => 
$outputType)"
+  }
+
+  def failedExecuteUserDefinedFunctionError(
+      funcCls: String, inputTypes: String, outputType: String, e: Exception): 
Throwable = {
+    new SparkException(udfErrorMessage(funcCls, inputTypes, outputType), e)
+  }
+
+  def divideByZeroError(): Throwable = {
+    new ArithmeticException("divide by zero")
+  }
+
+  def dataTypeUnsupportedByExtractValueError(
+      dataType: DataType, extraction: Expression, child: Expression): 
Throwable = {
+    val errorMsg = dataType match {
+      case StructType(_) =>
+        s"Field name should be String Literal, but it's $extraction"
+      case other =>
+        s"Can't extract value from $child: need struct type but got 
${other.catalogString}"
+    }
+    new AnalysisException(errorMsg)
+  }
+
+  def invalidArrayIndexError(index: Int, numElements: Int): Throwable = {
+    new ArrayIndexOutOfBoundsException(s"Invalid index: $index, numElements: 
$numElements")
+  }
+
+  def mapKeyNotExistsError(key: Any): Throwable = {
+    new NoSuchElementException(s"Key $key does not exist.")
+  }
+
+  def rowFromCSVParserNotExpectedError(): Throwable = {
+    new IllegalArgumentException("Expected one row from CSV parser.")
+  }
+
+  def inputTypeUnsupportedError(dataType: DataType): Throwable = {
+    new IllegalArgumentException(s"Unsupported input type 
${dataType.catalogString}")
+  }
+
+  def invalidFractionOfSecondError(): Throwable = {
+    new DateTimeException("The fraction of sec must be zero. Valid range is 
[0, 60].")
+  }
+
+  def overflowInSumOfDecimalError(): Throwable = {
+    new ArithmeticException("Overflow in sum of decimals.")
+  }
+
+  def mapSizeExceedArraySizeWhenZipMapError(size: Int): Throwable = {
+    new RuntimeException(s"Unsuccessful try to zip maps with $size " +
+      "unique keys due to exceeding the array size limit " +
+      s"${ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH}.")
+  }
+
+  def copyNullFieldNotAllowedError(): Throwable = {
+    new IllegalStateException("Do not attempt to copy a null field")
+  }
+
+  def literalTypeUnsupportedError(v: Any): Throwable = {
+    new RuntimeException(s"Unsupported literal type ${v.getClass} $v")
+  }
+
+  def noDefaultForDataTypeError(dataType: DataType): Throwable = {
+    new RuntimeException(s"no default for type $dataType")
+  }
+
+  def doGenCodeOfAliasShouldNotBeCalledError(): Throwable = {
+    new IllegalStateException("Alias.doGenCode should not be called.")
+  }
+
+  def orderedOperationUnsupportedByDataTypeError(dataType: DataType): 
Throwable = {
+    new IllegalArgumentException(s"Type $dataType does not support ordered 
operations")
+  }
+
+  def indexOfMatchGroupLessThanZeroNotAllowedError(): Throwable = {
+    new IllegalArgumentException("The specified group index cannot be less 
than zero")
+  }
+
+  def groupIndexExceedMatchGroupCountNotAllowedError(
+      groupCount: Int, groupIndex: Int): Throwable = {
+    new IllegalArgumentException(
+      s"Regex group count is $groupCount, but the specified group index is 
$groupIndex")
+  }
+
+  def invalidUrlError(url: UTF8String, e: URISyntaxException): Throwable = {
+    new IllegalArgumentException(s"Find an invaild url string 
${url.toString}", e)
+  }
+
+  def dataTypeUnsupportedError(): Throwable = {

Review comment:
       Yeah. `dataType` means the method not data type. I think 
`dataTypeUnsupportedError` is OK.
   We can change it as `dataTypeOperationUnsupportedError`.




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