Skip to content

Commit

Permalink
[SPARK-50084][SQL] Assign appropriate error condition for `_LEGACY_ER…
Browse files Browse the repository at this point in the history
…ROR_TEMP_3168`: `MISSING_TIMEOUT_CONFIGURATION`

### What changes were proposed in this pull request?

This PR proposes to assign proper error condition & sqlstate for `_LEGACY_ERROR_TEMP_3168`: `MISSING_TIMEOUT_CONFIGURATION`

### 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 #48620 from itholic/LEGACY_3168.

Authored-by: Haejoon Lee <haejoon.lee@databricks.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
  • Loading branch information
itholic authored and MaxGekk committed Oct 23, 2024
1 parent 5e9dec7 commit dcb4177
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3483,6 +3483,12 @@
],
"sqlState" : "42803"
},
"MISSING_TIMEOUT_CONFIGURATION" : {
"message" : [
"The operation has timed out, but no timeout duration is configured. To set a processing time-based timeout, use 'GroupState.setTimeoutDuration()' in your 'mapGroupsWithState' or 'flatMapGroupsWithState' operation. For event-time-based timeout, use 'GroupState.setTimeoutTimestamp()' and define a watermark using 'Dataset.withWatermark()'."
],
"sqlState" : "HY000"
},
"MISSING_WINDOW_SPECIFICATION" : {
"message" : [
"Window specification is not defined in the WINDOW clause for <windowName>. For more information about WINDOW clauses, please refer to '<docroot>/sql-ref-syntax-qry-select-window.html'."
Expand Down Expand Up @@ -8384,11 +8390,6 @@
"continuous mode is not supported!"
]
},
"_LEGACY_ERROR_TEMP_3168" : {
"message" : [
"hasTimedOut is true however there's no timeout configured"
]
},
"_LEGACY_ERROR_TEMP_3169" : {
"message" : [
"AcceptsLatestSeenOffset is not supported with DSv1 streaming source: <unsupportedSources>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private[sql] object GroupStateImpl {
throw new IllegalArgumentException("eventTimeWatermarkMs must be 0 or positive if present")
}
if (hasTimedOut && timeoutConf == NoTimeout) {
throw new SparkUnsupportedOperationException("_LEGACY_ERROR_TEMP_3168")
throw new SparkUnsupportedOperationException("MISSING_TIMEOUT_CONFIGURATION")
}

new GroupStateImpl[S](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ class GroupStateSuite extends SparkFunSuite {
TestGroupState.create[Int](
Optional.of(5), NoTimeout, 100L, Optional.empty[Long], hasTimedOut = true)
},
condition = "_LEGACY_ERROR_TEMP_3168",
condition = "MISSING_TIMEOUT_CONFIGURATION",
parameters = Map.empty)
checkError(
exception = intercept[SparkUnsupportedOperationException] {
GroupStateImpl.createForStreaming[Int](Some(5), 100L, NO_TIMESTAMP, NoTimeout, true, false)
},
condition = "_LEGACY_ERROR_TEMP_3168",
condition = "MISSING_TIMEOUT_CONFIGURATION",
parameters = Map.empty)
}

Expand Down

0 comments on commit dcb4177

Please sign in to comment.