Skip to content

Commit

Permalink
[SPARK-50156][SQL] Integrate _LEGACY_ERROR_TEMP_2113 into `UNRECOGN…
Browse files Browse the repository at this point in the history
…IZED_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]>
  • Loading branch information
itholic authored and MaxGekk committed Nov 6, 2024
1 parent fe70ca4 commit 4418f24
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 1 addition & 6 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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>."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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%'")
)
}

Expand Down

0 comments on commit 4418f24

Please sign in to comment.