A tool to visualize Apache Spark execution plans.
Project description
Spark Plan Viz
A lightweight, interactive tool to visualize and analyze PySpark execution plans using D3.js. It helps developers and data engineers debug complex queries when the textual result of df.explain() is not enough.
Documentation | Optimization Reference
Features
- Interactive Visualization: Zoom, pan, and click nodes to explore execution details
- 14-Rule Optimization Engine: Detects cross joins, missing broadcasts, full table scans, Python UDFs, and more
- Performance Insights: Instantly identify shuffles, broadcast joins, and pushed filters
- Jupyter Integration: Renders directly inside notebooks without external files
- Standalone HTML: Export visualizations to share with your team
- AQE Support: Full support for Adaptive Query Execution details
Installation
uv add spark-plan-viz
Or with pip:
pip install spark-plan-viz
Quick Start
Visualize
from spark_plan_viz import visualize_plan
# Renders inline in Jupyter
visualize_plan(df, notebook=True)
# Or export to HTML file
visualize_plan(df, notebook=False, output_file="my_plan.html")
Analyze
from spark_plan_viz import analyze_plan
suggestions = analyze_plan(df)
for s in suggestions:
print(f"[{s.severity.value}] {s.title}: {s.message}")
Example
from pyspark.sql import SparkSession
from pyspark.sql.functions import broadcast
from spark_plan_viz import visualize_plan
spark = SparkSession.builder.appName("Example").getOrCreate()
orders = spark.createDataFrame([
(1, "Alice", 100),
(2, "Bob", 200),
], ["id", "customer", "amount"])
customers = spark.createDataFrame([
("Alice", "NY"),
("Bob", "CA"),
], ["name", "state"])
result = orders.filter(orders.amount > 50) \
.join(broadcast(customers), orders.customer == customers.name) \
.groupBy("state") \
.agg({"amount": "sum"})
visualize_plan(result, notebook=True)
Requirements
- Python 3.11+
- PySpark 3.x+
- For notebook mode: IPython/Jupyter
Limitations
spark_plan_viz is not available on Databricks Serverless Compute, as it's not possible to access the _jdf object of a Spark DataFrame.
License
MIT License
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
Development Setup
git clone https://github.com/montanarograziano/spark_plan_viz.git
cd spark_plan_viz
just install
just pre-commit
just check
just test
Acknowledgments
Built with D3.js for interactive visualizations.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spark_plan_viz-1.0.0.tar.gz.
File metadata
- Download URL: spark_plan_viz-1.0.0.tar.gz
- Upload date:
- Size: 406.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d7a40efe3f80669e9ce600f04b12ea3a2bac5faf420a229670ef2ab3122db24
|
|
| MD5 |
8430167c1070e115ddd368344e37ed1f
|
|
| BLAKE2b-256 |
265c4db94dc22b910e28d79dbf15410317b6177c5620c352943f1286b9095733
|
Provenance
The following attestation bundles were made for spark_plan_viz-1.0.0.tar.gz:
Publisher:
release.yml on montanarograziano/spark_plan_viz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spark_plan_viz-1.0.0.tar.gz -
Subject digest:
5d7a40efe3f80669e9ce600f04b12ea3a2bac5faf420a229670ef2ab3122db24 - Sigstore transparency entry: 1154755189
- Sigstore integration time:
-
Permalink:
montanarograziano/spark_plan_viz@53d7acbfc9be475b365c40f0e0c413ffbfb940f1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/montanarograziano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@53d7acbfc9be475b365c40f0e0c413ffbfb940f1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file spark_plan_viz-1.0.0-py3-none-any.whl.
File metadata
- Download URL: spark_plan_viz-1.0.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0042c6cfcdf3da7a88cd1392b5c3c2ec9896d45f034f4080f27f02b034732cc5
|
|
| MD5 |
bd0d5d83a182c25d473a4479a5912475
|
|
| BLAKE2b-256 |
e6c5a04f62b307767f20e3d3de1f6c60e940c875187993e5db82a36230dbad66
|
Provenance
The following attestation bundles were made for spark_plan_viz-1.0.0-py3-none-any.whl:
Publisher:
release.yml on montanarograziano/spark_plan_viz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spark_plan_viz-1.0.0-py3-none-any.whl -
Subject digest:
0042c6cfcdf3da7a88cd1392b5c3c2ec9896d45f034f4080f27f02b034732cc5 - Sigstore transparency entry: 1154755190
- Sigstore integration time:
-
Permalink:
montanarograziano/spark_plan_viz@53d7acbfc9be475b365c40f0e0c413ffbfb940f1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/montanarograziano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@53d7acbfc9be475b365c40f0e0c413ffbfb940f1 -
Trigger Event:
push
-
Statement type: