Github user liancheng commented on the pull request:

    https://github.com/apache/spark/pull/5714#issuecomment-97330586
  
    Here is a simpler reproduction of this issue:
    
    ```scala
    import sqlContext.implicits._
    val df = sc.parallelize(Seq.empty[(Int, Int)]).toDF("key", "value").cache()
    println(df.queryExecution)
    ```
    
    output:
    
    ```
    == Parsed Logical Plan ==
    Project [_1#24 AS key#26,_2#25 AS value#27]
     LogicalRDD [_1#24,_2#25], MapPartitionsRDD[5] at mapPartitions at 
ExistingRDD.scala:35
    
    == Analyzed Logical Plan ==
    Project [_1#24 AS key#26,_2#25 AS value#27]
     LogicalRDD [_1#24,_2#25], MapPartitionsRDD[5] at mapPartitions at 
ExistingRDD.scala:35
    
    == Optimized Logical Plan ==
    Project [_1#24 AS key#26,_2#25 AS value#27]
     LogicalRDD [_1#24,_2#25], MapPartitionsRDD[5] at mapPartitions at 
ExistingRDD.scala:35
    
    == Physical Plan ==
    Project [_1#24 AS key#26,_2#25 AS value#27]
     PhysicalRDD [_1#24,_2#25], MapPartitionsRDD[5] at mapPartitions at 
ExistingRDD.scala:35
    
    Code Generation: false
    == RDD ==
    ```
    
    We can see that although `df` is cached, the query plan doesn't contain 
`InMemoryRelation`. The reason is that `DataFrame.persist()` calls 
`CacheManager.cacheQuery()` for some side effect (caching stuff), and then 
returns `this`. I'm thinking how about asking `DataFrame.persist()` to return a 
new `DataFrame` which shares the same logical plan but leverages cached data?


---
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