GitHub user zsxwing opened a pull request:

    https://github.com/apache/spark/pull/13815

    [SPARK-15443][SQL]Fix 'explain' for streaming Dataset

    ## What changes were proposed in this pull request?
    
    - Fix the `explain` command for streaming Dataset/DataFrame. E.g.,
    ```
    == Parsed Logical Plan ==
    'SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- 'MapElements <function1>, obj#6: java.lang.String
       +- 'DeserializeToObject 
unresolveddeserializer(createexternalrow(getcolumnbyordinal(0, 
StringType).toString, StructField(value,StringType,true))), obj#5: 
org.apache.spark.sql.Row
          +- Filter <function1>.apply
             +- StreamingRelation FileSource[/Users/zsx/stream], [value#0]
    
    == Analyzed Logical Plan ==
    value: string
    SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- MapElements <function1>, obj#6: java.lang.String
       +- DeserializeToObject createexternalrow(value#0.toString, 
StructField(value,StringType,true)), obj#5: org.apache.spark.sql.Row
          +- Filter <function1>.apply
             +- StreamingRelation FileSource[/Users/zsx/stream], [value#0]
    
    == Optimized Logical Plan ==
    SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- MapElements <function1>, obj#6: java.lang.String
       +- DeserializeToObject createexternalrow(value#0.toString, 
StructField(value,StringType,true)), obj#5: org.apache.spark.sql.Row
          +- Filter <function1>.apply
             +- StreamingRelation FileSource[/Users/zsx/stream], [value#0]
    
    == Physical Plan ==
    *SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- *MapElements <function1>, obj#6: java.lang.String
       +- *DeserializeToObject createexternalrow(value#0.toString, 
StructField(value,StringType,true)), obj#5: org.apache.spark.sql.Row
          +- *Filter <function1>.apply
             +- StreamingRelation FileSource[/Users/zsx/stream], [value#0]
    ```
    
    - Add `StreamingQuery.explain` to display the last execution plan. E.g.,
    ```
    == Parsed Logical Plan ==
    SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- MapElements <function1>, obj#6: java.lang.String
       +- DeserializeToObject createexternalrow(value#12.toString, 
StructField(value,StringType,true)), obj#5: org.apache.spark.sql.Row
          +- Filter <function1>.apply
             +- Relation[value#12] text
    
    == Analyzed Logical Plan ==
    value: string
    SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- MapElements <function1>, obj#6: java.lang.String
       +- DeserializeToObject createexternalrow(value#12.toString, 
StructField(value,StringType,true)), obj#5: org.apache.spark.sql.Row
          +- Filter <function1>.apply
             +- Relation[value#12] text
    
    == Optimized Logical Plan ==
    SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- MapElements <function1>, obj#6: java.lang.String
       +- DeserializeToObject createexternalrow(value#12.toString, 
StructField(value,StringType,true)), obj#5: org.apache.spark.sql.Row
          +- Filter <function1>.apply
             +- Relation[value#12] text
    
    == Physical Plan ==
    *SerializeFromObject [staticinvoke(class 
org.apache.spark.unsafe.types.UTF8String, StringType, fromString, input[0, 
java.lang.String, true], true) AS value#7]
    +- *MapElements <function1>, obj#6: java.lang.String
       +- *DeserializeToObject createexternalrow(value#12.toString, 
StructField(value,StringType,true)), obj#5: org.apache.spark.sql.Row
          +- *Filter <function1>.apply
             +- *Scan text [value#12] Format: 
org.apache.spark.sql.execution.datasources.text.TextFileFormat@1836ab91, 
InputPaths: file:/Users/zsx/stream/a.txt, file:/Users/zsx/stream/b.txt, 
file:/Users/zsx/stream/c.txt, PushedFilters: [], ReadSchema: 
struct<value:string>
    ```
    
    ## How was this patch tested?
    
    The added unit tests.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zsxwing/spark sdf-explain

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/13815.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13815
    
----
commit 404113fbba68280ab532b4c246a16ce948da33fb
Author: Shixiong Zhu <[email protected]>
Date:   2016-06-21T20:14:20Z

    Fix 'explain' for streaming Dataset

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to