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 8f0aca27916 [SPARK-38744][SQL][TESTS] Test the error class: NON_LITERAL_PIVOT_VALUES 8f0aca27916 is described below commit 8f0aca279168fba23695a4919a01b79dc776f21d Author: panbingkun <pbk1...@gmail.com> AuthorDate: Wed May 4 21:49:44 2022 +0300 [SPARK-38744][SQL][TESTS] Test the error class: NON_LITERAL_PIVOT_VALUES ## What changes were proposed in this pull request? This PR aims to add a test for the error class NON_LITERAL_PIVOT_VALUES to `QueryCompilationErrorsSuite`. ### 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 *QueryCompilationErrorsSuite*" ``` Closes #36431 from panbingkun/SPARK-38744. Authored-by: panbingkun <pbk1...@gmail.com> Signed-off-by: Max Gekk <max.g...@gmail.com> --- .../sql/errors/QueryCompilationErrorsSuite.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala index 252c7298cb5..40b18ad3cc7 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala @@ -525,6 +525,26 @@ class QueryCompilationErrorsSuite msg = "Field name m.n is invalid: m is not a struct.; line 1 pos 27") } } + + test("NON_LITERAL_PIVOT_VALUES: literal expressions required for pivot values") { + val df = Seq( + ("dotNET", 2012, 10000), + ("Java", 2012, 20000), + ("dotNET", 2012, 5000), + ("dotNET", 2013, 48000), + ("Java", 2013, 30000) + ).toDF("course", "year", "earnings") + + checkErrorClass( + exception = intercept[AnalysisException] { + df.groupBy(df("course")). + pivot(df("year"), Seq($"earnings")). + agg(sum($"earnings")).collect() + }, + errorClass = "NON_LITERAL_PIVOT_VALUES", + msg = "Literal expressions required for pivot values, found 'earnings#\\w+'", + matchMsg = true) + } } class MyCastToString extends SparkUserDefinedFunction( --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org