Skip to main content

SparkleFrame

SparkleFrame implements the PySpark DataFrame API so you can run transformation pipelines on a lightweight engine instead of a Spark cluster—no Spark cluster or Spark dependencies required. The engine is pluggable: Polars today, with a pure-Python engine in development. It is a partial shim aimed at the PySpark / Apache Spark 4.x DataFrame API: not every operation or edge case is supported, but behavior matches Spark where implemented.

Apache Spark is designed for distributed, large-scale data processing, but it is not optimized for low-latency use cases. There are scenarios, however, where you need to quickly re-compute certain data—for example, regenerating features for a machine learning model in real time or near-real time.

SparkleFrame is great for:

  • Users who want to run PySpark code quickly locally without the overhead of starting a Spark session
  • Users who want to run PySpark DataFrame code without the complexity of using Spark for processing
  • Useful for unit testing, feature prototyping, or serving small pipelines in microservices.

You can learn more about the design motivation behind Sparkleframe in this discussion thread.

Documentation

Full documentation is available at https://flypipe.github.io/sparkleframe/.

Installation

pip install sparkleframe

Usage

SparkleFrame can be used in two ways:

  • Directly importing the sparkleframe.polarsdf package
  • Using the activate function to allow for continuing to use pyspark.sql but have it use SparkleFrame behind the scenes.

Directly importing

If converting a PySpark pipeline, all pyspark.sql should be replaced with sparkleframe.polarsdf.

# PySpark import
# from pyspark.sql import SparkSession
# from pyspark.sql import functions as F
# from pyspark.sql.dataframe import DataFrame
# SparkleFrame import
from sparkleframe.polarsdf.session import SparkSession
from sparkleframe.polarsdf import functions as F
from sparkleframe.polarsdf.dataframe import DataFrame

Activating SparkleFrame

SparkleFrame can either replace pyspark imports or be used alongside them. To replace pyspark imports, use the activate function to set the engine to use.

from sparkleframe.activate import activate

# Activate SparkleFrame
activate()

from pyspark.sql import SparkSession
session = SparkSession.builder.getOrCreate()

SparkSession will now be a SparkleFrame Session object and everything will be run on Polars Dataframe directly.

SparkleFrame can also be directly imported which both maintains pyspark imports:

from sparkleframe.polarsdf.session import SparkSession
session = SparkSession.builder.getOrCreate()

Example Usage

from sparkleframe.activate import activate

# Activate SparkleFrame
activate()

from pyspark.sql import SparkSession
from pyspark.sql import functions as F

session = SparkSession.builder.getOrCreate()
df = session.createDataFrame(data=[{"col1": 1, "col2": 2}])
df = df.withColumn("col3", F.col("col2") + F.col("col1"))
>>> print(type(df))
<class 'sparkleframe.polarsdf.dataframe.DataFrame'>
>>> df.show()
shape: (1, 3)
┌──────┬──────┬──────┐
│ col1 ┆ col2 ┆ col3 │
│ ---  ┆ ---  ┆ ---  │
│ i64  ┆ i64  ┆ i64  │
╞══════╪══════╪══════╡
│ 1    ┆ 2    ┆ 3    │
└──────┴──────┴──────┘

!!! note

If you encounter any transformation that is not implemented, please open an [issue on GitHub](https://github.com/flypipe/sparkleframe/issues/new) so it can be prioritized.

Source Code

API code is available at https://github.com/flypipe/sparkleframe.

Contributing

See ARCHITECTURE.md for a map of the codebase, AGENTS.md for the contributor/agent guide, and docs/contributing/ for the detailed guides (testing, Spark 4 semantics, engines). Releases follow semantic versioning, driven by commit prefixes — see the release guide.

Metadata

Release files for sparkleframe 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sparkleframe 2.0.0
File Size Uploaded Provenance Actions
sparkleframe-2.0.0.tar.gz 952.6 kB Without provenance Details for sparkleframe-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sparkleframe 2.0.0
File Interpreter ABI Platform Actions
sparkleframe-2.0.0-py3-none-any.whl Python 3 none any Details for sparkleframe-2.0.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / sparkleframe-2.0.0.tar.gz

Download URL sparkleframe-2.0.0.tar.gz
Size 952.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d728844f960d318bcc770020ccb24aed7b4a6a5f8f58c2c50726db25551fb1e6
BLAKE2b-256 checksum
How to use checksums
83465a4307201581bbed6655f762eb88a73fe94555acffe7937e13cd098e3aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / sparkleframe-2.0.0-py3-none-any.whl

Download URL sparkleframe-2.0.0-py3-none-any.whl
Size 278.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1747cfc228ace56d354357688da96f2a878c9f39597ebd70971ede36f7a32111
BLAKE2b-256 checksum
How to use checksums
fc64d92bb1eae2bdaa22676523a5e51a567c8a3ceee1de926bc9df499cb44810
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Security for sparkleframe 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page