BlogApache Spark
Apache Spark
Releases, tutorials, and deep dives on Apache Spark from maintainers and practitioners across the open data ecosystem.
All Apache Spark posts
14 posts
An Idiot's Guide to UDFs and UDTFs in Spark
UDFs in Spark are extremely complicated. In this blog I break down scalar, aggregate and table functions in PySpark, SQL, Scala and Java, elucidating some of the concepts in a way that is hopefully, somewhat of a digestible entry point.
Apache Spark Metric Views: One Definition for Every Dashboard, Application, and AI Agent
Spark 4.2 made it a whole lot easier to define metrics once and query them consistently across an organization, including from dashboards, agents, and applications. They are already dead easy to use; in this blog I review metric views in Spark end to end for SQL lovers.
The Top 10 Data Engines in 2026, and What Each One Is Actually For
A ranked guide to the ten data engines that matter in 2026 (Apache Spark, Flink, DuckDB, Trino, DataFusion, Polars, ClickHouse, StarRocks, Ray and Velox), what each is best at, where it falls short, and how to choose.
Introducing Real-time Mode's Stateful Queries on Spark
A walkthrough of Structured Streaming and the stateful queries Spark 4.3 adds to Real-time Mode, using a bookshop that re-ranks its recommendations on every click and measures latency in both micro-batch and Real-time execution.
The Ultimate Guide to Apache Spark 4.3
Everything new in Apache Spark 4.3 and full feature breakdowns for stateful Real-time Mode, SCD Type 2 in Auto CDC, Project Feather, Spark Connect operation IDs and REST endpoints, DataFrame.zip and Python UDF transpilation, ASOF JOIN, JSON_TABLE, VARIANT edits, nanosecond timestamps and more.
Spark Connect from Rust: Pull Spark outputs into DuckDB and Polars
A guide to using the Apache Spark Connect client for Rust to integrate spark with DuckDB and Polars: start a Spark 4.2 server, get a result out as Arrow, hand it to DuckDB 2.0 for an ASOF join and to Polars for a rolling window, and write the answer back to Spark.
Building a Spark Connect Client in OCaml
How to build a Spark Connect client from the protocol up, in OCaml: compile the spark/connect protos, speak gRPC over HTTP/2 (ExecutePlan, AnalyzePlan, grpc-status-details-bin), build Relation and Expression plan trees with plan_id, decode the Arrow IPC batches each response carries, write Arrow for LocalRelation, and surface Spark error classes and SQLSTATEs. Includes the ocaml-protoc encoding bug behind 'Invalid protobuf byte sequence', a protocol coverage table tested on Spark 4.1.3, 4.2.0 and 4.3.0-rc1, and what the client still can't do.
An Idiot's Guide to Spark Connect Clients
Everything you need to go from "what is Spark?" to running jobs on a Spark Connect server from Python, Scala, Go, Rust or Swift, and working out what went wrong when it doesn't work.
TUTORIAL: How to Build an Open Lakehouse on Your Laptop
A self-contained tutorial that builds a complete open lakehouse in an empty folder, one layer at a time, from S3-compatible storage and Delta tables through Unity Catalog, Iceberg readers, declarative pipelines, Real-Time Mode and stateful streaming, Airflow and MLflow.
Hosting an Entire Open Lakehouse on Port 8080
Building lakehouse-at-home, a desktop stack for testing new Apache Spark and Iceberg releases before demoing them: Spark 4.0 and 4.1 side by side in Docker, Iceberg JDBC catalog on Postgres, SeaweedFS S3, Unity Catalog OSS, Kafka, Airflow with SparkPipelinesOperator, Spark Connect, Real-Time Mode latency on 4.1, and building an Iceberg runtime for a Spark 5.0 snapshot to test AUTO CDC. The exact Hadoop and AWS SDK pins, and every port collision on 8080.
Most PySpark Tuning Advice Starts in the Wrong Place
PySpark runs DataFrame code in the JVM at native speed, and almost everything that makes it slow happens where data crosses into Python. Ordered by how much each one bought in my own measurements: stay in the JVM, batch the crossing, don't produce the data, skip pandas for grouped work, take the JVM out of the client, and give Python the memory it actually uses.
Stop Blaming Serialization for Slow Python UDFs
Spark uses the word Arrow for a pandas conversion setting, a UDF transport and operator, and a data type your function receives. The difference between them is most of the difference in UDF performance, and my own benchmark confused two of them.
AUTO_CDC: Turning an event log into current state with Spark Declarative Pipelines
AUTO CDC (create_auto_cdc_flow) in Apache Spark 4.2 Declarative Pipelines, tested on messy data: SCD Type 1, keys, sequence_by, apply_as_deletes, out-of-order and stale events, and which targets work (Iceberg with JDBC, Hive, REST and Glue catalogs) and which don't (Parquet: AUTOCDC_TARGET_DOES_NOT_SUPPORT_MERGE; Delta, which lacks SupportsRowLevelOperations). The contract it leaves on your side: a unique, non-null sequence and deletes as events.
From Pickle to Arrow: A Decade of Moving Data Between Spark's JVM and Python
How Apache Arrow replaced pickle at every JVM-to-Python boundary in PySpark, from toPandas() in Spark 2.3 to pandas UDFs, mapInArrow, applyInArrow, Spark Connect, Arrow-optimized Python UDFs (useArrow=True) and @arrow_udf in 4.1, to the 4.2 defaults. Why spark.sql.execution.arrow.pyspark.enabled and spark.sql.execution.pythonUDF.arrow.enabled control different things, with benchmark numbers, and the one conversion that remains inside Spark's own engine.
