HyukjinKwon commented on a change in pull request #26861: 
[SPARK-30231][SQL][PYTHON] Support explain mode in PySpark df.explain
URL: https://github.com/apache/spark/pull/26861#discussion_r357073583
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
 ##########
 @@ -550,8 +551,35 @@ class Dataset[T] private[sql](
       case ExplainMode.Formatted =>
         qe.simpleString(formatted = true)
     }
+  }
+
+  /**
+   * Returns the plan (logical and physical) string with a format specified by 
a given explain mode.
+   *
+   * @group basic
+   * @since 3.0.0
+   */
+  def toExplainString(mode: String): String = {
+    mode.toLowerCase(Locale.ROOT) match {
+      case "simple" => toExplainString(ExplainMode.Simple)
+      case "extended" => toExplainString(ExplainMode.Extended)
+      case "codegen" => toExplainString(ExplainMode.Codegen)
+      case "cost" => toExplainString(ExplainMode.Cost)
+      case "formatted" => toExplainString(ExplainMode.Formatted)
+      case _ => throw new IllegalArgumentException(s"Unknown explain mode: 
$mode. Accepted " +
+        "explain modes are 'simple', 'extended', 'codegen', 'cost', 
'formatted'.")
+    }
+  }
+
+  /**
+   * Prints the plans (logical and physical) with a format specified by a 
given explain mode.
+   *
+   * @group basic
+   * @since 3.0.0
+   */
+  def explain(mode: ExplainMode): Unit = {
 
 Review comment:
   Yes, that was my thinking. WDYT?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to