-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-51822][SS] Throwing classified error when disallowed functions are called during StatefulProcessor.init() #50611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… StatefulProcessor.init()
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/DriverSideState.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithStateSuite.scala
Outdated
Show resolved
Hide resolved
|
@HeartSaVioR Can you PTAL when you get a chance? |
| } | ||
| } | ||
|
|
||
| private[sql] class DriverSideValueState[S](override val stateName: String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO DriverSide naming is confusing, I would expect some driver side functional state based on the name, while the actual implementation is not functional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ericm-db
Shall we rename it to represent InvalidHandle since you represented this as InvalidHandle in error method name? E.g. rename trait to InvalidHandleState and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sure, sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 pending CI
HeartSaVioR
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the change of rename - pending CI.
|
LGTM with nit (IMO delegation will be a better option here). |
|
@ericm-db Looks like CI failure is relevant. |
|
The crux of the issue is that in a test we do the following: where we fetch MapState and cast it to MapStateImplWithTTL. MapStateImplWithTTL is not a private class, so this is technically allowed behavior, but since InvalidHandleMapState does not inherit or extend the Impl class, this throws an error. |
|
One way is do pattern match and fail if the type is not expected "on demand" - when the variable is accessed in test, it is NOT from driver side of init. |
|
@HeartSaVioR this change should be good to merge |
HeartSaVioR
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
Thanks! Merging to master. |
What changes were proposed in this pull request?
When state variable operations are called within the init() function of the StatefulProcessorHandle, a NullPointerException is thrown, failing the query (even through this is user error).
Throw an error with a message that better describes the issue.
Why are the changes needed?
The NullPointerException doesn't describe the issue to the user, even though this is user error. This will let them know that the function they are calling within
init()is disallowed.Does this PR introduce any user-facing change?
Before this change:
After this change:
How was this patch tested?
Unit tests
Was this patch authored or co-authored using generative AI tooling?
No