Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14030#discussion_r69823441
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/ForeachSink.scala
 ---
    @@ -30,7 +32,42 @@ import org.apache.spark.sql.{DataFrame, Encoder, 
ForeachWriter}
     class ForeachSink[T : Encoder](writer: ForeachWriter[T]) extends Sink with 
Serializable {
     
       override def addBatch(batchId: Long, data: DataFrame): Unit = {
    -    data.as[T].foreachPartition { iter =>
    +    // TODO: Refine this method when SPARK-16264 is resolved; see comments 
below.
    +
    +    // This logic should've been as simple as:
    +    // ```
    +    //   data.as[T].foreachPartition { iter => ... }
    +    // ```
    +    //
    +    // Unfortunately, doing that would just break the incremental planing. 
The reason is,
    +    // `Dataset.foreachPartition()` would further call `Dataset.rdd()`, 
but `Dataset.rdd()` just
    +    // does not support `IncrementalExecution`.
    +    //
    +    // So as a provisional fix, below we've made a special version of 
`Dataset` with its `rdd()`
    +    // method supporting incremental planning. But in the long run, we 
should generally make newly
    +    // created Datasets use `IncrementalExecution` where necessary (which 
is SPARK-16264 tries to
    +    // resolve).
    +
    +    val dataAsT = data.as[T]
    +    val datasetWithIncrementalExecution =
    +      new Dataset(data.sparkSession, dataAsT.logicalPlan, dataAsT.encoder) 
{
    --- End diff --
    
    `dataAsT` can be removed. You can use `implicitly[Encoder[T]]` to get the 
encoder. Please also revert the change to 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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to