Skip to content

[Backport 4.x][SPARK-56324] Add ZeroCopyByteStream to enable PySpark <-> Spark message-based communication#55732

Closed
sven-weber-db wants to merge 1 commit intoapache:branch-4.xfrom
sven-weber-db:sven-weber_data/zero-copy-backport-4.x
Closed

[Backport 4.x][SPARK-56324] Add ZeroCopyByteStream to enable PySpark <-> Spark message-based communication#55732
sven-weber-db wants to merge 1 commit intoapache:branch-4.xfrom
sven-weber-db:sven-weber_data/zero-copy-backport-4.x

Conversation

@sven-weber-db
Copy link
Copy Markdown
Contributor

@sven-weber-db sven-weber-db commented May 7, 2026

What changes were proposed in this pull request?

This is a back port of master commit 2e14b92 into Spark branch 4.x.
You can verify that this back port contains the same changes by running the following:

git format-patch -1 2e14b92 > patch.1
git format-patch -1 7e08a46 > patch.2
diff patch.1 patch.2

Which will produce empty output (there is no difference)

Why are the changes needed?

Forgot to merge the PR into branch 4.x in addition to master.

Does this PR introduce any user-facing change?

No - like the original PR

How was this patch tested?

New unit-testa have been introduced.

Was this patch authored or co-authored using generative AI tooling?

Partially, yes. However, the code is manually reviewed and adjusted.

…age-based communication

### What changes were proposed in this pull request?

This is the first in a series of PRs that introduce message-based communication to PySpark UDFs. This initiative is part of [SPIP SPARK-55278](https://issues.apache.org/jira/browse/SPARK-55278), which proposes language-agnostic UDFs.

The goal of introducing message-based communication to PySpark is to:

1. Make the communication between Spark <-> PySpark more structured.
2. Enable new communication protocols (e.g., gRPC) transparently.

The overall goal is to introduce a second communication channel while keeping the existing channel intact. Specifically, we want to introduce gRPC in addition to UDS. The existing UDS channel will not be changed, and its characteristics, including performance, will remain untouched.

As the first step to make PySpark communication message-based, this PR introduces a new class, which implements a file-like interface on top of a stream of byte arrays. This class will be used in follow-up PRs to provide raw gRPC-transmitted bytes to PySpark.

### Why are the changes needed?

This is the first step toward a language-agnostic UDF protocol for Spark that enables UDF workers written in any language to communicate with the Spark engine through a well-defined specification and API boundary. The abstractions introduced here will be used to make PySpark transport layer agnostic, which is required for PySpark to support the new protocol.

### Does this PR introduce _any_ user-facing change?

No. There will be follow-up PRs to consume the introduced abstractions.

### How was this patch tested?

New unit tests have been added for the new modules.

### Was this patch authored or co-authored using generative AI tooling?

Partially, yes. However, the code is manually reviewed and adjusted.

Closes apache#55515 from sven-weber-db/sven-weber_data/ZeroCopyByte.

Authored-by: Sven Weber <sven.weber@databricks.com>
Signed-off-by: Daniel Tenedorio <daniel.tenedorio@databricks.com>
@sven-weber-db sven-weber-db marked this pull request as ready for review May 7, 2026 14:56
@dtenedor
Copy link
Copy Markdown
Contributor

dtenedor commented May 7, 2026

LGTM, merging to 4.x

dtenedor pushed a commit that referenced this pull request May 7, 2026
…<-> Spark message-based communication

### What changes were proposed in this pull request?

This is a back port of master commit 2e14b92 into Spark branch 4.x.
You can verify that this back port contains the same changes by running the following:

```bash
git format-patch -1 2e14b92 > patch.1
git format-patch -1 7e08a46 > patch.2
diff patch.1 patch.2
```

Which will produce empty output (there is no difference)

### Why are the changes needed?

Forgot to merge the PR into branch 4.x in addition to master.

### Does this PR introduce _any_ user-facing change?

No - like the original PR

### How was this patch tested?

New unit-testa have been introduced.

### Was this patch authored or co-authored using generative AI tooling?

Partially, yes. However, the code is manually reviewed and adjusted.

Closes #55732 from sven-weber-db/sven-weber_data/zero-copy-backport-4.x.

Authored-by: Sven Weber <sven.weber@databricks.com>
Signed-off-by: Daniel Tenedorio <daniel.tenedorio@databricks.com>
@sven-weber-db
Copy link
Copy Markdown
Contributor Author

Closing as the change was merged. Thank you!

@sven-weber-db sven-weber-db deleted the sven-weber_data/zero-copy-backport-4.x branch May 7, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants