Skip to content

ForeachWriter

ForeachWriter is the <> for a foreach writer that is a streaming format that controls streaming writes.

Note

ForeachWriter is set using DataStreamWriter.foreach operator.

val foreachWriter = new ForeachWriter[String] { ... }
streamingQuery.
  writeStream.
  foreach(foreachWriter).
  start

=== [[contract]] ForeachWriter Contract

[source, scala]

package org.apache.spark.sql

abstract class ForeachWriter[T] { def open(partitionId: Long, version: Long): Boolean def process(value: T): Unit def close(errorOrNull: Throwable): Unit }


.ForeachWriter Contract [cols="1,2",options="header",width="100%"] |=== | Method | Description

| [[open]] open | Used when...

| [[process]] process | Used when...

| [[close]] close | Used when... |===