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 0900419de8c [SPARK-43591][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_0013 0900419de8c is described below commit 0900419de8ca5d98b9921ec9ad2a8783e995f09c Author: panbingkun <pbk1...@gmail.com> AuthorDate: Mon May 22 23:49:50 2023 +0300 [SPARK-43591][SQL] Assign a name to the error class _LEGACY_ERROR_TEMP_0013 ### What changes were proposed in this pull request? The pr aims to assign a name to the error class _LEGACY_ERROR_TEMP_0013. ### Why are the changes needed? The changes improve the error framework. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass GA. Closes #41236 from panbingkun/SPARK-43591. Lead-authored-by: panbingkun <pbk1...@gmail.com> Co-authored-by: panbingkun <84731...@qq.com> Signed-off-by: Max Gekk <max.g...@gmail.com> --- core/src/main/resources/error/error-classes.json | 27 ++++++++-- .../spark/sql/errors/QueryParsingErrors.scala | 6 +-- .../sql/catalyst/parser/PlanParserSuite.scala | 62 ++++++++++++++++++++-- 3 files changed, 82 insertions(+), 13 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index fbb94c59e0e..af0471199b7 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -1311,6 +1311,28 @@ ], "sqlState" : "42000" }, + "NOT_ALLOWED_IN_FROM" : { + "message" : [ + "Not allowed in the FROM clause:" + ], + "subClass" : { + "LATERAL_WITH_PIVOT" : { + "message" : [ + "LATERAL together with PIVOT." + ] + }, + "LATERAL_WITH_UNPIVOT" : { + "message" : [ + "LATERAL together with UNPIVOT." + ] + }, + "UNPIVOT_WITH_PIVOT" : { + "message" : [ + "UNPIVOT together with PIVOT." + ] + } + } + }, "NOT_A_PARTITIONED_TABLE" : { "message" : [ "Operation <operation> is not allowed for <tableIdentWithDB> because it is not a partitioned table." @@ -2209,11 +2231,6 @@ "DISTRIBUTE BY is not supported." ] }, - "_LEGACY_ERROR_TEMP_0013" : { - "message" : [ - "LATERAL cannot be used together with PIVOT in FROM clause." - ] - }, "_LEGACY_ERROR_TEMP_0014" : { "message" : [ "TABLESAMPLE does not accept empty inputs." diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala index 4b6c3645916..28abaeb70ec 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala @@ -102,15 +102,15 @@ private[sql] object QueryParsingErrors extends QueryErrorsBase { } def unpivotWithPivotInFromClauseNotAllowedError(ctx: ParserRuleContext): Throwable = { - new ParseException("UNPIVOT cannot be used together with PIVOT in FROM clause", ctx) + new ParseException(errorClass = "NOT_ALLOWED_IN_FROM.UNPIVOT_WITH_PIVOT", ctx) } def lateralWithPivotInFromClauseNotAllowedError(ctx: ParserRuleContext): Throwable = { - new ParseException(errorClass = "_LEGACY_ERROR_TEMP_0013", ctx) + new ParseException(errorClass = "NOT_ALLOWED_IN_FROM.LATERAL_WITH_PIVOT", ctx) } def lateralWithUnpivotInFromClauseNotAllowedError(ctx: ParserRuleContext): Throwable = { - new ParseException("LATERAL cannot be used together with UNPIVOT in FROM clause", ctx) + new ParseException(errorClass = "NOT_ALLOWED_IN_FROM.LATERAL_WITH_UNPIVOT", ctx) } def lateralJoinWithUsingJoinUnsupportedError(ctx: ParserRuleContext): Throwable = { diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala index 76be620f7bc..41e941da908 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala @@ -567,7 +567,7 @@ class PlanParserSuite extends AnalysisTest { "select * from t lateral view posexplode(x) posexpl as x, y", expected) - val sql = + val sql1 = """select * |from t |lateral view explode(x) expl @@ -575,7 +575,7 @@ class PlanParserSuite extends AnalysisTest { | sum(x) | FOR y IN ('a', 'b') |)""".stripMargin - val fragment = + val fragment1 = """from t |lateral view explode(x) expl |pivot ( @@ -583,13 +583,65 @@ class PlanParserSuite extends AnalysisTest { | FOR y IN ('a', 'b') |)""".stripMargin checkError( - exception = parseException(sql), - errorClass = "_LEGACY_ERROR_TEMP_0013", + exception = parseException(sql1), + errorClass = "NOT_ALLOWED_IN_FROM.LATERAL_WITH_PIVOT", parameters = Map.empty, context = ExpectedContext( - fragment = fragment, + fragment = fragment1, start = 9, stop = 84)) + + val sql2 = + """select * + |from t + |lateral view explode(x) expl + |unpivot ( + | val FOR y IN (x) + |)""".stripMargin + val fragment2 = + """from t + |lateral view explode(x) expl + |unpivot ( + | val FOR y IN (x) + |)""".stripMargin + checkError( + exception = parseException(sql2), + errorClass = "NOT_ALLOWED_IN_FROM.LATERAL_WITH_UNPIVOT", + parameters = Map.empty, + context = ExpectedContext( + fragment = fragment2, + start = 9, + stop = 74)) + + val sql3 = + """select * + |from t + |lateral view explode(x) expl + |pivot ( + | sum(x) + | FOR y IN ('a', 'b') + |) + |unpivot ( + | val FOR y IN (x) + |)""".stripMargin + val fragment3 = + """from t + |lateral view explode(x) expl + |pivot ( + | sum(x) + | FOR y IN ('a', 'b') + |) + |unpivot ( + | val FOR y IN (x) + |)""".stripMargin + checkError( + exception = parseException(sql3), + errorClass = "NOT_ALLOWED_IN_FROM.UNPIVOT_WITH_PIVOT", + parameters = Map.empty, + context = ExpectedContext( + fragment = fragment3, + start = 9, + stop = 115)) } test("joins") { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org