This is an automated email from the ASF dual-hosted git repository. maxgekk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new c80de3b67ae [SPARK-41044][SQL] Convert DATATYPE_MISMATCH.UNSPECIFIED_FRAME to INTERNAL_ERROR c80de3b67ae is described below commit c80de3b67ae05d8c17d9afef9655ad2e76bfd05f Author: panbingkun <pbk1...@gmail.com> AuthorDate: Fri Nov 11 12:27:28 2022 +0300 [SPARK-41044][SQL] Convert DATATYPE_MISMATCH.UNSPECIFIED_FRAME to INTERNAL_ERROR ### What changes were proposed in this pull request? The pr aims to convert DATATYPE_MISMATCH.UNSPECIFIED_FRAME to INTERNAL_ERROR. ### Why are the changes needed? 1. When I work on https://issues.apache.org/jira/browse/SPARK-41021, I can't found the path to trigger it from the user's perspective, then we should convert it to an internal error.(https://github.com/apache/spark/pull/38520/files#r1015171962) 2. The changes improve the error framework. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? 1. Update existed UT. 2. Pass GA. Closes #38555 from panbingkun/convert_UNSPECIFIED_FRAME_to_INNER_ERROR. Authored-by: panbingkun <pbk1...@gmail.com> Signed-off-by: Max Gekk <max.g...@gmail.com> --- core/src/main/resources/error/error-classes.json | 5 ----- .../spark/sql/catalyst/expressions/windowExpressions.scala | 8 +++++--- .../catalyst/analysis/ExpressionTypeCheckingSuite.scala | 14 ++++++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index 63978e6be66..5d1fdbbdc05 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -349,11 +349,6 @@ "cannot find a static method <methodName> that matches the argument types in <className>" ] }, - "UNSPECIFIED_FRAME" : { - "message" : [ - "Cannot use an UnspecifiedFrame. This should have been converted during analysis." - ] - }, "UNSUPPORTED_INPUT_TYPE" : { "message" : [ "The input of <functionName> can't be <dataType> type data." diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala index 353ab22b5a5..c32bf4d4d45 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala @@ -19,6 +19,7 @@ package org.apache.spark.sql.catalyst.expressions import java.util.Locale +import org.apache.spark.SparkException import org.apache.spark.sql.catalyst.analysis.{TypeCheckResult, UnresolvedException} import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{DataTypeMismatch, TypeCheckSuccess} import org.apache.spark.sql.catalyst.dsl.expressions._ @@ -57,8 +58,8 @@ case class WindowSpecDefinition( frameSpecification = newChildren.last.asInstanceOf[WindowFrame]) override lazy val resolved: Boolean = - childrenResolved && checkInputDataTypes().isSuccess && - frameSpecification.isInstanceOf[SpecifiedWindowFrame] + childrenResolved && frameSpecification.isInstanceOf[SpecifiedWindowFrame] && + checkInputDataTypes().isSuccess override def nullable: Boolean = true override def dataType: DataType = throw QueryExecutionErrors.dataTypeOperationUnsupportedError @@ -66,7 +67,8 @@ case class WindowSpecDefinition( override def checkInputDataTypes(): TypeCheckResult = { frameSpecification match { case UnspecifiedFrame => - DataTypeMismatch(errorSubClass = "UNSPECIFIED_FRAME") + throw SparkException.internalError("Cannot use an UnspecifiedFrame. " + + "This should have been converted during analysis.") case f: SpecifiedWindowFrame if f.frameType == RangeFrame && !f.isUnbounded && orderSpec.isEmpty => DataTypeMismatch(errorSubClass = "RANGE_FRAME_WITHOUT_ORDER") diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ExpressionTypeCheckingSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ExpressionTypeCheckingSuite.scala index 256cf439b65..d406ec8f74a 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ExpressionTypeCheckingSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ExpressionTypeCheckingSuite.scala @@ -17,7 +17,7 @@ package org.apache.spark.sql.catalyst.analysis -import org.apache.spark.SparkFunSuite +import org.apache.spark.{SparkException, SparkFunSuite} import org.apache.spark.sql.AnalysisException import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.DataTypeMismatch import org.apache.spark.sql.catalyst.dsl.expressions._ @@ -810,11 +810,13 @@ class ExpressionTypeCheckingSuite extends SparkFunSuite with SQLHelper with Quer UnresolvedAttribute("a") :: Nil, SortOrder(UnresolvedAttribute("b"), Ascending) :: Nil, UnspecifiedFrame) - assert(wsd.checkInputDataTypes() == - DataTypeMismatch( - errorSubClass = "UNSPECIFIED_FRAME", - messageParameters = Map.empty - ) + checkError( + exception = intercept[SparkException] { + wsd.checkInputDataTypes() + }, + errorClass = "INTERNAL_ERROR", + parameters = Map("message" -> ("Cannot use an UnspecifiedFrame. " + + "This should have been converted during analysis.")) ) } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org