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 8548a8221cf [SPARK-38738][SQL][TESTS] Test the error class: INVALID_FRACTION_OF_SECOND 8548a8221cf is described below commit 8548a8221cf0e00a1801ee105e5a0942b5ecfb56 Author: panbingkun <pbk1...@gmail.com> AuthorDate: Sat Apr 16 21:49:46 2022 +0300 [SPARK-38738][SQL][TESTS] Test the error class: INVALID_FRACTION_OF_SECOND ## What changes were proposed in this pull request? This pr aims to add one test for the error class INVALID_FRACTION_OF_SECOND to `QueryExecutionErrorsSuite`. ### Why are the changes needed? The changes improve test coverage, and document expected error messages in tests. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? By running new test: ``` $ build/sbt "sql/testOnly *QueryExecutionErrorsSuite*" ``` Closes #36211 from panbingkun/SPARK-38738. Lead-authored-by: panbingkun <pbk1...@gmail.com> Co-authored-by: Maxim Gekk <max.g...@gmail.com> Signed-off-by: Max Gekk <max.g...@gmail.com> --- .../spark/sql/errors/QueryExecutionErrorsSuite.scala | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala index d3c242266be..09f655431dc 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala @@ -21,7 +21,7 @@ import java.util.Locale import test.org.apache.spark.sql.connector.JavaSimpleWritableDataSource -import org.apache.spark.{SparkArithmeticException, SparkException, SparkIllegalStateException, SparkRuntimeException, SparkUnsupportedOperationException, SparkUpgradeException} +import org.apache.spark.{SparkArithmeticException, SparkDateTimeException, SparkException, SparkIllegalStateException, SparkRuntimeException, SparkUnsupportedOperationException, SparkUpgradeException} import org.apache.spark.sql.{DataFrame, QueryTest} import org.apache.spark.sql.catalyst.util.BadRecordException import org.apache.spark.sql.connector.SimpleWritableDataSource @@ -388,4 +388,16 @@ class QueryExecutionErrorsSuite extends QueryTest |""".stripMargin) } } + + test("INVALID_FRACTION_OF_SECOND: in the function make_timestamp") { + withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") { + val e = intercept[SparkDateTimeException] { + sql("select make_timestamp(2012, 11, 30, 9, 19, 60.66666666)").collect() + } + assert(e.getErrorClass === "INVALID_FRACTION_OF_SECOND") + assert(e.getSqlState === "22023") + assert(e.getMessage === "The fraction of sec must be zero. Valid range is [0, 60]. " + + "If necessary set spark.sql.ansi.enabled to false to bypass this error. ") + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org