[SPARK-55275] SQL State Coverage: IllegalStateException#54056
[SPARK-55275] SQL State Coverage: IllegalStateException#54056garlandz-db wants to merge 9 commits intoapache:masterfrom
Conversation
JIRA Issue Information=== Improvement SPARK-55275 === This comment was automatically generated by GitHub Actions |
6d21971 to
ae01b8c
Compare
0676a45 to
3432de2
Compare
| @@ -90,7 +90,7 @@ class SparkDeclarativePipelinesServerTest extends SparkConnectServerTest with St | |||
| if (iter.hasNext) { | |||
| iter.next() | |||
| } else { | |||
| throw new IllegalStateException(s"Invalid response: $iter") | |||
| throw IllegalStateErrors.noBatchesAvailable() | |||
aa03ab3 to
3ad3fb4
Compare
| @@ -332,7 +333,7 @@ case class SessionHolder(userId: String, sessionId: String, session: SparkSessio | |||
| // called only once, since removing the session from SparkConnectSessionManager.sessionStore is | |||
| // synchronized and guaranteed to happen only once. | |||
| if (closedTimeMs.isDefined) { | |||
| throw new IllegalStateException(s"Session $key is already closed.") | |||
| throw IllegalStateErrors.sessionAlreadyClosed(sessionId) | |||
| "value" -> value, | ||
| "context" -> context)) | ||
|
|
||
| def cleanerAlreadySet(queryKey: String): SparkIllegalStateException = |
There was a problem hiding this comment.
I was wondering if it makes sense to have two message parameters—userId and sessionId—instead of queryKey.
There was a problem hiding this comment.
the query id and run id are whats previously thrown. we can also include that
3ad3fb4 to
088ae2c
Compare
| sessionId: $sessionId with status ${status} | ||
| is not within statuses $validStatuses for event $eventStatus | ||
| """) | ||
| throw IllegalStateErrors.sessionStateTransitionInvalid(status.toString, eventStatus.toString) |
There was a problem hiding this comment.
sessionId and validStatuses are missing?
28c7b12 to
684123f
Compare
|
Early LGTM — please fix the test failures accordingly. I also noticed a few unused subclasses (e.g., DATA_INTEGRITY_OPERATION_ID_MISMATCH, SESSION_MANAGEMENT_SERVER_SESSION_ID_CHANGED). Could you clean those up accordingly? One final thing: some error messages (e.g., “Attempting to stop the Spark Connect service that has not been started”) are being lost. Could you fix that as well? |
| @@ -46,11 +46,13 @@ object InvalidPlanInput { | |||
| InvalidPlanInput( | |||
| errorCondition = "INTERNAL_ERROR", | |||
| messageParameters = Map("message" -> message), | |||
| causeOpt = None) | |||
| causeOpt = None, | |||
| sqlState = Some("56K00")) | |||
There was a problem hiding this comment.
On second thought, it may not be a good idea to include this custom mapping in the code. It breaks the assumption that each error condition corresponds to a single SQL state. You might also need to change the error condition to a new one and store this mapping in error-conditions.json.
|
|
||
| def apply(errorCondition: String, messageParameters: Map[String, String]): InvalidPlanInput = | ||
| InvalidPlanInput( | ||
| errorCondition = errorCondition, | ||
| messageParameters = messageParameters, | ||
| causeOpt = None) | ||
| causeOpt = None, | ||
| sqlState = Some("56K00")) |
|
One good practice is to split a larger PR into smaller ones so that it is easier for reviewers to handle. In this case, it may be easier to review if we split the changes for IllegalStateExceptions and InvalidPlanInput into separate PRs. |
| @@ -455,8 +456,7 @@ object SparkConnectService extends Logging { | |||
| } | |||
|
|
|||
| if (!started) { | |||
| throw new IllegalStateException( | |||
| "Attempting to stop the Spark Connect service that has not been started.") | |||
| throw IllegalStateErrors.serviceNotStarted() | |||
There was a problem hiding this comment.
Friendly ping on this. It seems that some error messages (e.g., “Attempting to stop the Spark Connect service that has not been started”) are still being lost
There was a problem hiding this comment.
updated good catch!
4051ebc to
8277b78
Compare
| val eventSender = new PipelineEventSender(mockObserver, mockSessionHolder) | ||
| eventSender.shutdown() | ||
| intercept[IllegalStateException] { | ||
| intercept[SparkIllegalStateException] { |
There was a problem hiding this comment.
You don't have to do this right? We are still throwing an IllegalStateException right?
There was a problem hiding this comment.
i did it to validate the changes but yes we can change it back
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.sql.connect.service.{ExecuteStatus, SessionStatus} | ||
|
|
||
| class IllegalStateErrorsSuite extends SparkFunSuite { |
There was a problem hiding this comment.
I am not sure I love this class. It is super mechanical, and relatively low yield. Don't we have existing tests for this, that we can tighten up?
|
@garlandz-db can you look at the test failures? |
…alStateException Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move sqlState before subClass to match Jackson ORDER_MAP_ENTRIES_BY_KEYS alphabetical ordering required by SparkThrowableSuite. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c117941 to
f345a37
Compare
|
CI is flaking. rebasing off master |
What changes were proposed in this pull request?
Update IllegalStateException => SparkIllegalStateException in spark connect layer
Why are the changes needed?
This keeps the Spark Connect layer more traceable for errors
Does this PR introduce any user-facing change?
Yes. Changes exception type to their Spark equivalent
How was this patch tested?
Updated testing
Was this patch authored or co-authored using generative AI tooling?
Yes