spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdas <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-15593][SQL]Add DataFrameWriter.foreach ...
Date Fri, 27 May 2016 01:18:00 GMT
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13342#discussion_r64845888
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -358,6 +360,35 @@ final class DataFrameWriter private[sql](df: DataFrame) {
       }
     
       /**
    +   * :: Experimental ::
    +   * Starts the execution of the streaming query, which will continually send results
to the given
    +   * [[ForeachWriter]] as new data arrives. The returned [[ContinuousQuery]] object can
be used to
    +   * interact with the stream.
    +   *
    +   * @since 2.0.0
    +   */
    +  @Experimental
    +  def foreach(writer: ForeachWriter[T]): ContinuousQuery = {
    +    val queryName = extraOptions.getOrElse("queryName", StreamExecution.nextName)
    +    val checkpointLocation = extraOptions.get("checkpointLocation")
    +      .orElse {
    +        df.sparkSession.sessionState.conf.checkpointLocation.map { l =>
    +          new Path(l, queryName).toUri.toString
    +        }
    +      }.getOrElse {
    +      throw new AnalysisException("checkpointLocation must be specified either " +
    +        "through option() or SQLConf")
    +    }
    +
    +    df.sparkSession.sessionState.continuousQueryManager.startQuery(
    --- End diff --
    
    We have to clean the closure of the Writer and check for its serializability. Otherwise
it might capture unexpected stuff in the closure and fail later.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message