This directory contains the .proto files that define the Spark Connect protocol.
After modifying any .proto file here, regenerate the Python stubs under python/pyspark/sql/connect/proto/ using one of the two methods below.
This method does not require any local tool installation and produces a reproducible environment.
From the root of the Spark repository:
docker build -t connect-cg \ --build-context root=. \ dev/spark-test-image/connect-gen-protos/
The root build context points at the Spark repository root so the Dockerfile can COPY pyproject.toml for dependency installation.
From the root of the Spark repository:
docker run --cpus 1 -it --rm -v "$(pwd)":/spark connect-cg
The container mounts the repository at /spark, runs dev/connect-gen-protos.sh inside the container, and writes the generated files to python/pyspark/sql/connect/proto/ in your local checkout.
Install the required tools:
buf — protobuf code generatorInstall the required Python packages. Check pyproject.toml for the latest pinned versions of mypy, mypy-protobuf, and ruff, then run:
pip install 'mypy==<version>' 'mypy-protobuf==<version>' 'ruff==<version>'
For example, based on the current pyproject.toml:
pip install 'mypy==1.19.1' 'mypy-protobuf==3.3.0' 'ruff==0.14.8'
From the root of the Spark repository:
./dev/connect-gen-protos.sh
The generated Python files will be written to python/pyspark/sql/connect/proto/.
You can also generate to a custom output directory by passing a path:
./dev/connect-gen-protos.sh /tmp/my-proto-output