-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
[SPARK-46875][SQL] When the mode
is null, a NullPointException
should not
be thrown
#44900
Conversation
case _ => | ||
logWarning(s"$v is not a valid parse mode. Using ${PermissiveMode.name}.") | ||
PermissiveMode | ||
} | ||
}.getOrElse { | ||
logWarning(s"mode is null and not a valid parse mode. Using ${PermissiveMode.name}.") | ||
PermissiveMode |
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.
Shouldn't we show an error on the wrong error instead of silently fallback to the PERMISSIVE
mode? cc @HyukjinKwon
I mean both case - null and a wrong mode.
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.
@MaxGekk
In the current logic, when mode is null, the following error is displayed:
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.
I suggest we have two options
as follows:
1.If the mode
is null, it will fall back to PermissiveMode
, just like setting a non-null error value for the mode
.
2.If mode
is null, we throw a user-friendly error prompt instead of a NullPointerException
.
The fix change for this PR adopts the first
option.
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.
Probably, the fallback to the PERMISSIVE
mode looks much more consistent with current approach of not-recognised value. We could stick on it in your PR, but I think it is better to change behaviour and throw appropriate error in both cases.
mode
is null, a NullPointException
should not
be thrown
+1, LGTM. Merging to master. |
What changes were proposed in this pull request?
The pr aims to provide better prompts when option's
mode
is null.Why are the changes needed?
In the original logic, if the mode is null, Spark will throw a
NullPointerException
, which is obviously unfriendly to the user.Before:
After:
It will fall back to
PermissiveMode
mode and then display the data normally, as shown below:Does this PR introduce any user-facing change?
Yes, When
mode
is null, it fallback toPermissiveMode
instead of throwing aNullPointerException
.How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
No.