HyukjinKwon opened a new pull request #28711:
URL: https://github.com/apache/spark/pull/28711


   ### What changes were proposed in this pull request?
   
   Scala:
   
   ```scala
   scala> spark.range(10).explain("cost")
   ```
   ```
   == Optimized Logical Plan ==
   Range (0, 10, step=1, splits=Some(12)), Statistics(sizeInBytes=80.0 B)
   
   == Physical Plan ==
   *(1) Range (0, 10, step=1, splits=12)
   ```
   
   PySpark:
   
   ```python
   >>> spark.range(10).explain("cost")
   ```
   ```
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/.../spark/python/pyspark/sql/dataframe.py", line 333, in explain
       raise TypeError(err_msg)
   TypeError: extended (optional) should be provided as bool, got <class 'str'>
   ```
   
   This is also consistent with `DataFrame.sample` case.
   
   ### Why are the changes needed?
   
   To provide the consistent API support across APIs.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Nope, it's only changes in unreleased branches.
   If this lands to master only, yes, users will be able to set `mode` as 
`df.explain("...")` in Spark 3.1.
   
   ### How was this patch tested?
   
   Unittest was added and manually tested as well to make sure:
   
   ```python
   spark.range(10).explain(True)
   spark.range(10).explain(False)
   spark.range(10).explain("cost")
   spark.range(10).explain(extended="cost")
   spark.range(10).explain(mode="cost")
   spark.range(10).explain()
   spark.range(10).explain(True, "cost")
   spark.range(10).explain(1.0)
   ```
   
   


----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to