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 bb29a3f8e658 [SPARK-50069][SQL] Integrate `_LEGACY_ERROR_TEMP_0028`
into `UNSUPPORTED_FROM_TO_EXPRESSION`
bb29a3f8e658 is described below
commit bb29a3f8e6585d8649c2e6760aced295eb6ac4ae
Author: Haejoon Lee <[email protected]>
AuthorDate: Tue Oct 29 14:52:33 2024 +0100
[SPARK-50069][SQL] Integrate `_LEGACY_ERROR_TEMP_0028` into
`UNSUPPORTED_FROM_TO_EXPRESSION`
### What changes were proposed in this pull request?
This PR proposes to Integrate `_LEGACY_ERROR_TEMP_0028` into
`UNSUPPORTED_FROM_TO_EXPRESSION`
### Why are the changes needed?
To improve the error message by assigning proper error condition and
SQLSTATE
### Does this PR introduce _any_ user-facing change?
No, only user-facing error message improved
### How was this patch tested?
Updated the existing tests
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #48597 from itholic/LEGACY_0028.
Authored-by: Haejoon Lee <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
---
common/utils/src/main/resources/error/error-conditions.json | 5 -----
.../org/apache/spark/sql/errors/QueryParsingErrors.scala | 11 +++++++++--
.../spark/sql/catalyst/parser/ExpressionParserSuite.scala | 4 ++--
.../sql-tests/analyzer-results/ansi/interval.sql.out | 4 +++-
.../resources/sql-tests/analyzer-results/interval.sql.out | 4 +++-
.../test/resources/sql-tests/results/ansi/interval.sql.out | 4 +++-
.../src/test/resources/sql-tests/results/interval.sql.out | 4 +++-
7 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/common/utils/src/main/resources/error/error-conditions.json
b/common/utils/src/main/resources/error/error-conditions.json
index a09a05de1a45..f6ed1291457f 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -5760,11 +5760,6 @@
"The value of from-to unit must be a string."
]
},
- "_LEGACY_ERROR_TEMP_0028" : {
- "message" : [
- "Intervals FROM <from> TO <to> are not supported."
- ]
- },
"_LEGACY_ERROR_TEMP_0029" : {
"message" : [
"Cannot mix year-month and day-time fields: <literal>."
diff --git
a/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
b/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
index a9e556fad046..0fa6eb0434ab 100644
---
a/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
+++
b/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
@@ -284,9 +284,16 @@ private[sql] object QueryParsingErrors extends
DataTypeErrorsBase {
from: String,
to: String,
ctx: ParserRuleContext): Throwable = {
+ val intervalInput = ctx.getText()
+ val pattern = "'([^']*)'".r
+ val input = pattern.findFirstMatchIn(intervalInput) match {
+ case Some(m) => m.group(1)
+ case None => ""
+ }
+
new ParseException(
- errorClass = "_LEGACY_ERROR_TEMP_0028",
- messageParameters = Map("from" -> from, "to" -> to),
+ errorClass = "INVALID_INTERVAL_FORMAT.UNSUPPORTED_FROM_TO_EXPRESSION",
+ messageParameters = Map("input" -> input, "from" -> from, "to" -> to),
ctx)
}
diff --git
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
index 6d307d1cd9a8..fc8bcfa3f687 100644
---
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
+++
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
@@ -1082,8 +1082,8 @@ class ExpressionParserSuite extends AnalysisTest {
// Unknown FROM TO intervals
checkError(
exception = parseException("interval '10' month to second"),
- condition = "_LEGACY_ERROR_TEMP_0028",
- parameters = Map("from" -> "month", "to" -> "second"),
+ condition = "INVALID_INTERVAL_FORMAT.UNSUPPORTED_FROM_TO_EXPRESSION",
+ parameters = Map("input" -> "10", "from" -> "month", "to" -> "second"),
context = ExpectedContext(
fragment = "'10' month to second",
start = 9,
diff --git
a/sql/core/src/test/resources/sql-tests/analyzer-results/ansi/interval.sql.out
b/sql/core/src/test/resources/sql-tests/analyzer-results/ansi/interval.sql.out
index b0d128c4cab6..c023e3b56f11 100644
---
a/sql/core/src/test/resources/sql-tests/analyzer-results/ansi/interval.sql.out
+++
b/sql/core/src/test/resources/sql-tests/analyzer-results/ansi/interval.sql.out
@@ -1233,9 +1233,11 @@ select interval '1' year to second
-- !query analysis
org.apache.spark.sql.catalyst.parser.ParseException
{
- "errorClass" : "_LEGACY_ERROR_TEMP_0028",
+ "errorClass" : "INVALID_INTERVAL_FORMAT.UNSUPPORTED_FROM_TO_EXPRESSION",
+ "sqlState" : "22006",
"messageParameters" : {
"from" : "year",
+ "input" : "1",
"to" : "second"
},
"queryContext" : [ {
diff --git
a/sql/core/src/test/resources/sql-tests/analyzer-results/interval.sql.out
b/sql/core/src/test/resources/sql-tests/analyzer-results/interval.sql.out
index efa149509751..c0196bbe118e 100644
--- a/sql/core/src/test/resources/sql-tests/analyzer-results/interval.sql.out
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/interval.sql.out
@@ -1233,9 +1233,11 @@ select interval '1' year to second
-- !query analysis
org.apache.spark.sql.catalyst.parser.ParseException
{
- "errorClass" : "_LEGACY_ERROR_TEMP_0028",
+ "errorClass" : "INVALID_INTERVAL_FORMAT.UNSUPPORTED_FROM_TO_EXPRESSION",
+ "sqlState" : "22006",
"messageParameters" : {
"from" : "year",
+ "input" : "1",
"to" : "second"
},
"queryContext" : [ {
diff --git
a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
index b2f85835eb0d..766bfba7696f 100644
--- a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
@@ -1535,9 +1535,11 @@ struct<>
-- !query output
org.apache.spark.sql.catalyst.parser.ParseException
{
- "errorClass" : "_LEGACY_ERROR_TEMP_0028",
+ "errorClass" : "INVALID_INTERVAL_FORMAT.UNSUPPORTED_FROM_TO_EXPRESSION",
+ "sqlState" : "22006",
"messageParameters" : {
"from" : "year",
+ "input" : "1",
"to" : "second"
},
"queryContext" : [ {
diff --git a/sql/core/src/test/resources/sql-tests/results/interval.sql.out
b/sql/core/src/test/resources/sql-tests/results/interval.sql.out
index 5471dafaec8e..7eed2d42da04 100644
--- a/sql/core/src/test/resources/sql-tests/results/interval.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/interval.sql.out
@@ -1422,9 +1422,11 @@ struct<>
-- !query output
org.apache.spark.sql.catalyst.parser.ParseException
{
- "errorClass" : "_LEGACY_ERROR_TEMP_0028",
+ "errorClass" : "INVALID_INTERVAL_FORMAT.UNSUPPORTED_FROM_TO_EXPRESSION",
+ "sqlState" : "22006",
"messageParameters" : {
"from" : "year",
+ "input" : "1",
"to" : "second"
},
"queryContext" : [ {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]