Skip to main content

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)

example visualization

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

spark_plan_viz-1.0.0.tar.gz (406.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spark_plan_viz-1.0.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

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

Hashes for spark_plan_viz-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5d7a40efe3f80669e9ce600f04b12ea3a2bac5faf420a229670ef2ab3122db24
MD5 8430167c1070e115ddd368344e37ed1f
BLAKE2b-256 265c4db94dc22b910e28d79dbf15410317b6177c5620c352943f1286b9095733

See more details on using hashes here.

Provenance

The following attestation bundles were made for spark_plan_viz-1.0.0.tar.gz:

Publisher: release.yml on montanarograziano/spark_plan_viz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for spark_plan_viz-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0042c6cfcdf3da7a88cd1392b5c3c2ec9896d45f034f4080f27f02b034732cc5
MD5 bd0d5d83a182c25d473a4479a5912475
BLAKE2b-256 e6c5a04f62b307767f20e3d3de1f6c60e940c875187993e5db82a36230dbad66

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page