[SPARK-30231][SQL][PYTHON][FOLLOWUP] Make error messages clear in PySpark df.explain
### What changes were proposed in this pull request? This pr is a followup of #26861 to address minor comments from viirya. ### Why are the changes needed? For better error messages. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? Manually tested. Closes #26886 from maropu/SPARK-30231-FOLLOWUP. Authored-by: Takeshi Yamamuro <yamamuro@apache.org> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
This commit is contained in:
parent
46e950bea8
commit
f483a13d4a
|
@ -305,11 +305,12 @@ class DataFrame(object):
|
|||
is_mode_case = mode is not None and isinstance(mode, basestring)
|
||||
|
||||
if not is_no_argument and not (is_extended_case or is_mode_case):
|
||||
argtypes = [
|
||||
str(type(arg)) for arg in [extended, mode] if arg is not None]
|
||||
raise TypeError(
|
||||
"extended (optional) and mode (optional) should be a bool and str; "
|
||||
"however, got [%s]." % ", ".join(argtypes))
|
||||
if extended is not None:
|
||||
errMsg = "extended (optional) should be provided as bool" \
|
||||
", got {0}".format(type(extended))
|
||||
else: # For mode case
|
||||
errMsg = "mode (optional) should be provided as str, got {0}".format(type(mode))
|
||||
raise TypeError(errMsg)
|
||||
|
||||
# Sets an explain mode depending on a given argument
|
||||
if is_no_argument:
|
||||
|
|
|
@ -547,6 +547,7 @@ class Dataset[T] private[sql](
|
|||
}
|
||||
}
|
||||
|
||||
// This method intends to be called from PySpark DataFrame
|
||||
private[sql] def toExplainString(mode: String): String = {
|
||||
mode.toLowerCase(Locale.ROOT) match {
|
||||
case "simple" => toExplainString(ExplainMode.Simple)
|
||||
|
|
Loading…
Reference in a new issue