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 4418f24a03f4 [SPARK-50156][SQL] Integrate `_LEGACY_ERROR_TEMP_2113` 
into `UNRECOGNIZED_STATISTIC`
4418f24a03f4 is described below

commit 4418f24a03f483aff5da040b13bf920f1e00e3e1
Author: Haejoon Lee <[email protected]>
AuthorDate: Wed Nov 6 09:01:18 2024 +0100

    [SPARK-50156][SQL] Integrate `_LEGACY_ERROR_TEMP_2113` into 
`UNRECOGNIZED_STATISTIC`
    
    ### What changes were proposed in this pull request?
    
    This PR proposes to Integrate `_LEGACY_ERROR_TEMP_2113` into 
`UNRECOGNIZED_STATISTIC`
    
    ### 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 #48692 from itholic/LEGACY_2113.
    
    Authored-by: Haejoon Lee <[email protected]>
    Signed-off-by: Max Gekk <[email protected]>
---
 common/utils/src/main/resources/error/error-conditions.json        | 7 +------
 .../scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala   | 6 +++---
 .../src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala   | 6 +++---
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/common/utils/src/main/resources/error/error-conditions.json 
b/common/utils/src/main/resources/error/error-conditions.json
index 18603b61d8ae..b8722f26105d 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -4765,7 +4765,7 @@
   },
   "UNRECOGNIZED_STATISTIC" : {
     "message" : [
-      "The statistic <stats> is not recognized. Valid statistics include 
`count`, `count_distinct`, `approx_count_distinct`, `mean`, `stddev`, `min`, 
`max`, and percentile values."
+      "The statistic <stats> is not recognized. Valid statistics include 
`count`, `count_distinct`, `approx_count_distinct`, `mean`, `stddev`, `min`, 
`max`, and percentile values. Percentile must be a numeric value followed by 
'%', within the range 0% to 100%."
     ],
     "sqlState" : "42704"
   },
@@ -7164,11 +7164,6 @@
       "Unexpected window function frame <frame>."
     ]
   },
-  "_LEGACY_ERROR_TEMP_2113" : {
-    "message" : [
-      "Unable to parse <stats> as a percentile."
-    ]
-  },
   "_LEGACY_ERROR_TEMP_2115" : {
     "message" : [
       "Unknown column: <unknownColumn>."
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
index 2cc223ba69fa..a32016eee61f 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
@@ -1155,15 +1155,15 @@ private[sql] object QueryExecutionErrors extends 
QueryErrorsBase with ExecutionE
   def cannotParseStatisticAsPercentileError(
       stats: String, e: NumberFormatException): SparkIllegalArgumentException 
= {
     new SparkIllegalArgumentException(
-      errorClass = "_LEGACY_ERROR_TEMP_2113",
-      messageParameters = Map("stats" -> stats),
+      errorClass = "UNRECOGNIZED_STATISTIC",
+      messageParameters = Map("stats" -> toSQLValue(stats)),
       cause = e)
   }
 
   def statisticNotRecognizedError(stats: String): 
SparkIllegalArgumentException = {
     new SparkIllegalArgumentException(
       errorClass = "UNRECOGNIZED_STATISTIC",
-      messageParameters = Map("stats" -> toSQLId(stats)))
+      messageParameters = Map("stats" -> toSQLValue(stats)))
   }
 
   def unknownColumnError(unknownColumn: String): SparkIllegalArgumentException 
= {
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
index 37319de0b662..6581cf07d8e9 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameStatSuite.scala
@@ -589,15 +589,15 @@ class DataFrameStatSuite extends QueryTest with 
SharedSparkSession {
         person2.summary("foo")
       },
       condition = "UNRECOGNIZED_STATISTIC",
-      parameters = Map("stats" -> "`foo`")
+      parameters = Map("stats" -> "'foo'")
     )
 
     checkError(
       exception = intercept[SparkIllegalArgumentException] {
         person2.summary("foo%")
       },
-      condition = "_LEGACY_ERROR_TEMP_2113",
-      parameters = Map("stats" -> "foo%")
+      condition = "UNRECOGNIZED_STATISTIC",
+      parameters = Map("stats" -> "'foo%'")
     )
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to