---
title: write (DataSourceStreamWriter)
description: "DataSourceStreamWriter.write method in PySpark: Writes data into the streaming sink."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/classes/datasourcestreamwriter/write
---

# write (DataSourceStreamWriter)

Writes data into the streaming sink.

This method is called on executors to write data to the streaming data sink in each microbatch. It accepts an iterator of input data and returns a single row representing a commit message, or `None` if there is no commit message.

The driver collects commit messages, if any, from all executors and passes them to the `commit()` method if all tasks run successfully. If any task fails, the `abort()` method will be called with the collected commit messages.

## Syntax

```
write(iterator: Iterator[Row])
```

## Parameters

| Parameter  | Type           | Description                |
| ---------- | -------------- | -------------------------- |
| `iterator` | Iterator\[Row] | An iterator of input data. |

## Returns

`WriterCommitMessage`

A serializable commit message.
