Skip to content

Examples maintained in PySparky repositories

The style guide and Cookbook on this site teach native PySpark patterns. These separate repositories provide complete local exercises, including their own tests and pinned toolchains. Follow each repository's README for the current setup and supported versions.

Test PySpark code

The how-to-test-your-spark repository shows how a small function can be checked both without starting Spark and against a real local Spark session:

  • Its examples.py contains a lazy table-read and projection function.
  • A mock-based unit test checks call wiring; a local Spark test uses an explicit schema and synthetic rows to verify the result.
  • The integration test's collect() is an intentional action over two local rows. The fixture uses local[1], fixes the session timezone and shuffle count, and removes its temporary view after the test.

Start with the repository's README for setup and commands. Its checked tuple is CPython 3.10.22 or 3.11.18, PySpark/Spark 3.5.8, and Temurin Java 17.0.21.1+2.

Protobuf with PySpark

The Protobuf-example repository uses a synthetic person schema to demonstrate a local binary-column round trip:

  • main.py builds lazy from_protobuf and to_protobuf transformations and starts a local session only in its explicit command-line entry point.
  • The integration test checks the round trip with synthetic data; the schema is the source for its descriptor.
  • Its README documents the generated Python example, compiler commands, and the external Spark connector. Running Spark downloads the pinned Maven connector and dependencies.

See the repository's README for setup, generation, and test commands. The checked tuple is CPython 3.10.22 or 3.11.18, Spark/PySpark 3.5.8 with Scala 2.12, Temurin Java 17.0.21.1+2, and protoc 29.6.

These repositories are educational examples, not package compatibility promises. Check each project's own README, metadata, and CI before relying on a version combination. The linked source and documentation are MIT licensed within each repository's stated scope. The Protobuf notebook retains its separate Apache-2.0 license, and the repository ignore templates retain CC0. This page links to maintained sources rather than copying their code.