Skip to main content

The Upcoming Apache Spark™ 4.1: The Next Chapter in Unified Analytics

Summary

  • Spark 4.1 release: Apache Spark's next version optimizes both massive cluster deployments and local laptop development for unified analytics.
  • Pythonization: Major enhancements include simpler installation, clearer error messages, and more Pythonic APIs for data scientists and engineers.
  • Real-time streaming: Spark 4.1 adds native plotting, data source flexibility, and Spark Connect support for seamless local-to-distributed execution.

The Upcoming Apache Spark™ 4.1: The Next Chapter in Unified Analytics

Watch: The Upcoming Apache Spark™ 4.1: The Next Chapter in Unified Analytics
Talk by DB Tsai, Senior Engineering Manager, Databricks ; Xiao Li, Engineering Director, Databricks
Apache Spark has long been recognized as the leading open-source unified analytics engine, combining a simple yet powerful API with a rich ecosystem and top-notch performance. In the upcoming Spark 4.1 release, the community reimagines Spark to excel at both massive cluster deployments and local laptop development. We’ll start with new single-node optimizations that make PySpark even more efficient for smaller datasets. Next, we’ll delve into a major “Pythonizing” overhaul — simpler installation, clearer error messages and Pythonic APIs. On the ETL side, we’ll explore greater data source flexibility (including the simplified Python Data Source API) and a thriving UDF ecosystem. We’ll also highlight enhanced support for real-time use cases, built-in data quality checks and the expanding Spark Connect ecosystem — bridging local workflows with fully distributed execution. Don’t miss this chance to see Spark’s next chapter!
Here’s more to explore:
Production ready data pipelines for analytics and AI: https://www.databricks.com/solutions/data-engineering
The Big Book of Data Engineering: https://www.databricks.com/resources/ebook/big-book-data-engineering-2nd-edition
See all the product announcements from Data + AI Summit: https://www.databricks.com/events/dataaisummit-2025-announcements

Chapters

FAQs

What are the major features in Apache Spark 4.1?

Spark 4.1 includes single-node optimizations for laptops, major Pythonization improvements, enhanced data source APIs, real-time streaming support, and Spark Connect for bridging local and distributed execution. This video covers all these advancements from the Databricks engineering team.

How does Spark 4.1 improve the Python development experience?

The Pythonization overhaul simplifies installation, provides clearer error messages, introduces Pythonic APIs (moving away from Java/Scala patterns), and includes native visualization directly in PySpark. This makes Spark more accessible to Python developers.

What is the Python Data Source API in Spark 4.1?

The Python Data Source API allows developers to build custom connectors in pure Python without diving into Scala or Java. This video shows how AI can even auto-generate data sources, opening the door to a larger community of contributors.

Who are the speakers presenting on Spark 4.1 updates?

DB Tsai (Senior Engineering Manager) and Xiao Li (Engineering Director) from Databricks present the latest Spark 4.1 features and roadmap.

Full transcript

0:00 Introduction to Spark 4.1

Hello everyone. So welcome to this talk. Um today we'll talk about the latest updates in 4. 1 release. Um like I'm shi um and the DB and I um basically work for Dicks and the longtime uh Spark meter and PMC member. Um Spark 4. 0 Z was released like two weeks ago. Uh this is a major milestone for the community. Uh it contains like over 5,000 resolve jur um and there more than 400 contributors um for this release. So this is a huge community efforts.

0:26 Spark 4.0 Ecosystem updates

The release sets a foundation for the 4. x line. So thank you everyone for contributing to this release. So spark has almost 50,000 commits and 880,000 to code review comments. So this is a decade uh of sustained growth. So community are from the different countries. Um the diversity keeps the spar relevant for every use case. And the pi also shows spar pispar was downloaded in 214 countries and regions last year and the spark is everywhere.
So monthly pi downloads and maven downloads this is just open source pi and maven um now tops 93 millions. So basically I mean many company the production relies on the spark um everywhere um for data processing. So all this community efforts are fit into sparks mission to be a unified analytics engine one platform that handles batch streaming SQL MR on any data source in any environment on prem cloud kubernetes. So this principles guide our road map for four points.
So spark kubernetes operators uh is now an official sub project of spark native kubernetes management for spark. So we have released three version uh this year um spark 4. 0 zero added a Python data source APIs so simple to use so we can even autogenerate the data source with AI uh we'll show like example laterally writing a custom data source required Scala Java expertise so data source v2 is a complicated so many APIs performance knobs so this data source API pass data source API opens the door for a larger community to build connectors since you can do it in Passport without diving into the GBM.
So I mean uh the community this year already uh implemented a many data source for example lens db good sheet s hunting face github please contribute to your data source spark 4. x delivers a lot for python developers uh in 4. 0 zero native plotting uh now you can visualize the data frame directly um and data source API I just mentioned and also streaming uh like arbitrary stful processing v2 API um and also we integrate pispar or spark system with arrow with this udf applying arrow and you can also convert your data to arrow then you can directly use this arrow library with spark mark um and also the pispar binary uh image now has a more than 400 megabyte so it's pretty big so that's why with a spark connect technology we introduce a lightweight Python cloud just like 1.
5 megabytes very tiny very small you can install deploy it everywhere like to your mobile um in 4. 1 um we are talking about is um released um in this talk like for example uh deter pipeline temporary table udf debugging um real time streaming we also continue to optimize the python data source like column pruning and predict push down so we can get a better performance using the python data source spar 4. 0 Z also made major improvement for SQL users like we turn on NC U by default.
So SQL behaves spark SQL behaves closer to standard SQL like a stricter type checking error invalidator um and improved correctness and the UDF UDTF actually this very popular uh like a feature circle features in debits like almost all the debits customer are using this so we open source it in 4. 0 and also many other circle feature like correlation section variables yeah you can try the 4. 0 zero and the smart 4. 1 um will focus on the SQL enhancement tool like Flumpo um I mean derative pipelines will be also available in the SQL so that means actually we added two important features with declarative pipeline one is streaming table so that means you can run streaming using SQL syntax now uh with declarative pipeline and mater has view.
So that's also very popular features community is asking. So in the 4. 1 we'll start the support of the method view. Um and also script scripting secret stop procedure recursivity um like many new data type from time data type special um special geo data type will be also available and uh with spark connect the spark driver is now decoupled with from the client. So any language like Scala, Python, Swift, Go, Rust can talk to Spark.
So now you can choose any language you like. 4. 0 delivery features across syntax, streaming, connect usability. I don't want to repeat this. Tomorrow Daniel and Wan will give talk about 4. 0 release. So now um we just this talks we'll focus on the 4. 1 features. I will cover the first three and DB will cover the remaining three. Detail pipeline. I believe most of you already use bar to write some data processing pipeline.

7:00 Declarative pipelines

Normally it's the imperative. You can see you basically read some table for example here is using streaming and write I mean then you do some filter uh generate another table and write to this the second table table two and also you can write other filters and write to the um table three then join the table two and table three together okay and write to table four um but this actually is pretty painful I mean if you look at the code you'll figure out oh the table two and table three actually can be executed in parallel they don't have dependency however for many user I saw like they just run it sequentially like some people just ask oh can we just um run multiple sales at same times in the notebook actually notebook is hard to tell whether this like the two jobs or two um execution have a dependency so that's why this is a common pen um so when you build a pipeline it's complicated coordination You need to consider the schema mismatch and also you need to um like handle dependency um the table the job could change right semantic could change so you also need to basically um handle like airflow dbt yeah this like uh external tools is communicating so I mean this example basically shows you have to explain how to do it step by step with a very details this is painful and hard to maintain However, at sometimes we can use a deterative way to describe how to achieve that, right?
Just need to tell what to achieve, what to do. So like SL API is a typical declarative API for people in spark in the past like the 10 years basically at the very beginning we provide the RDD API, Dream API. This is imperative API and then in the and then later I mean to make spark simple we introduced a dataf frame API SQL API search streaming and made spar user happy. However, can we extend the spark derative model from individual queries to entire query plan?
The answer is yes. This release will introduce a spar derative pipeline. Tomorrow Michael will announce this in the keynotes and uh yeah so basically the idea is simple. We just um instead of specifying the every step we just specify the entire pipeline up front and then you execute it with one command. Spark will take care of figure out the execution plan for the whole pipeline and uh schedule this parts of a pip pipeline in correct order paralyze them if possible handle streaming batch execution details for you all automatically under the hood spark native that means this is part of a spark new components you use a spark API API circle API and taken to the high level spar will handle all the optimization infrastructure for you.

10:30 Pipeline runner and execution

So then yeah so starting from 4. 1 we hope we can provide a Python and SQL first in the future we can provide more API based on spark connect like I just mentioned any language you can choose the second part is a pipeline runner so this is the new concept new component we introduced for the SDP so this will take the pipeline definition actually executed. So you can can think of this is extension to the spark scheduleuler or optimizer.
So this will operate at a pipeline level. It will analyze all the deterioration definition you define and uh determine the correct execution plan. Then the runner will start stream transformation ensure things happen in the right order automatically. So basically it's a job is doing the job that we are human are doing that at that time I mean manually at this moment. So here just like the py python examples you can here just like a define the customer table not table it's like a uh like a query the t is a um customer read from the CSV file you define another um like a table orders uh read string from the cafa and then you join them together and define another fact orders you don't need to execute you just need to define them then you run this command spar pipelines run I mean spar will handle all the details for you SQL you can do the same thing create streaming table from the capa create method view for CSV files um then you join them together and under the hood spar will feed out automatically for you handle parallelism uh ordering validation and uh you just need to you can choose two different I mean the execution mode um like a batch or continuously so compare with maybe also use a DBT you can we can compare this two are similar so DBT basically focus on SQL SDB will focus on the spark you of course you can also like push down the uh like a SQL to the underlying data source uh like a SQL data source v JDBC connectors you can define the subquery push down the whole query to the underlying uh secret warehouse and the language it support the Python SQL and more language in the future dbt focus on the SQL and the processing we can support the batch streaming uh DBT basically focus on the batch and our m primary users data engineers and the DB DBT's analytics.
Okay. So, tomorrow uh we'll have a two talks for uh DBT. So, my uh will show more details. If you are interesting, please join. Okay, let's talk about streaming. Streaming jobs is pretty popular. It grows 60% year-over-year. And uh so we want to introduce a new execution mode, realtime streaming mode. it can achieve like 100 milliseconds. So it's like ultra low latency for the operational um like use cases. So if you use a micro batch it can in most cases it only can handle streaming injection and ETR.

13:38 Real-time streaming mode

Now I mean Spartan provide both you don't need to run other engine for the this real time streaming use cases. I mean for streaming users no API change. What you need to do is just change the trigger from the processing time trigger to realtime trigger. That's it. It's very simple based on internal benchmark. It is 20 times 30 30 time faster than metro batch. The high ideas are simple. They're scheduling all task with steady TD slots and they reserve that capacity for much longer period of time and then not a typical micro batch that consistent get executed.
So we enable data to flow so the building operators and your customer code and send computed results to downstream immediately. So the this is a longer batch basically it's a micro batch mode bridge the streaming into micro smaller batch right um coordination scheduling uh like sequential execution um but the new like a mode uh sorry so new data must wait uh until the current numerical batch to finish uh before being processed.
So it cause like a latency flow. In real time mode, all stages can execute concurrently in a continuous pipeline. The task persist across the time. This elimmit the stop and go batch overhead and significantly reduce per record latency. We also introduce streaming shuffle. So that means intermediate results are pushed directly to downstream as soon as as soon as they are like produced instead of waiting for entire upstream stage uh to complete.
So this non-blocking streaming enables records to prop propagate so the processing pipeline in near real time. So for tolerance we keep the same for tolerance. So offset our checkpoint only at end of each long runninging batch. So um if a failure occurs during the batch um the entire batch is retrieded from the last committed offset. So no data is lost and skipped. So real time streaming is 10 or 30 times faster. Microbatch still wins for the sout and the cost when the subsecond latency isn't is not needed for your use case.
So there's many use cases for the real time mode and of course at this moment real time streaming still has a limitation it only support like stful operations at least once capa for each sync uh we expand we will improve the support so we also have a I mean u streaming talk please join there are two talks about streaming real time streaming okay geni Now how GI changes smart development 92% of use US developers already start use or plan to use AI coding tools.

17:35 AI-powered development

So ARM is a good add coding. 2023 people are using documentation overflow set overflow. CHBT helps. CHBT is I mean reduce the time efforts for the users to write a spark code. But in the future actually ID agent can write a spark code for you and call runtime API directly. So we are trying to figure out what we can do to improve this like a code quality. So first is a how about a new feature new API uh we need to produce a spark code high quality spark code um we need to improve the documentation examples error message and machine learn I mean for the machine to read to pass.
So here we just example like we just mentioned the patent data source right. Uh if we directly ask actually the code that cannot run just like very I mean run I mean the message API everything is wrong. So but however if we provide examples like this repository contains like 10 uh different pattern data source actually trag can generate very good ledger code without errors it's amazing I mean um please try offline um so at the same times we're also trying to figure out how can we improve capability of the spark I know it's very painful for everyone including myself.
Um actually yeah AI agent can write a good code right can can can they like the debard for you um spar has a many internal like structure states matches logs. So how can we provide this information to you I mean AI spar UI is designed for expert not for AI. So we need to figure out how to expose this to the AI. So this is still ongoing. Um and also um we want to improve our release. I mean currently is too slow. Six months, one year, two years.
We need speed up. Um so we want to like introduce monthly preview build for early adopter. People can provide the feedbacks directly and also we want to reduce minimize behavior change for API. So a I mean AI can generate the code better. Um and uh of course if we want to change behavior we should document all the behaviors. Okay DB DB will continue to introduce the remaining features. Yeah. Thank you. Um yeah so my name is DB.
I'm going to talk about the rest of the stuff uh in the slide. Um so I'm gonna cover data source uh some of the uh new foundation and also some of the SQL feature. So what's the data source API? So uh in spar the data source API is an interface where we enable uh spar to read data or write data to external data source. Right? So some example can be like a park, CSV, JSON, data, iceberg, you know, JDBC all them are like a data source and this is an interface where we interface with spark and external data source.

20:47 Data source API v2

So uh everyone know that uh you know DSV1 DSV2 uh you know it's it there are a lots of uh um you know new investment in DSV2 but we need to ask a question right why DSB1 has problem and why we are uh you know making investment in DSB2 so when we design the DSB1 we don't have enough uh good like you know uh abstraction over the API. So basically uh the data source implementation will rely on a lot of the low-level API such as SQL context RDD and this leak out some of the SPA internal implementation to the connector and this really difficult for different data source to have a consistent implementation of behavior like a safe DML CDC or store procedure right so different data source can have a different implementation different behavior area and it's really hard to unify and it's also hard to evolve and also in DSV1 there's no catalog support so we don't have also support for the structural streaming and we also miss a lot of important uh DML feature like a delete update merge and also some of the optimization optimize right so also have some other limitation we can uh we're going to talk about so what's the current uh you know uh DSB2 um situation uh right now.
So currently uh DSB2 uh is getting more and more traction in the data source developer. uh it's move a lot of complexity from you know data source implementation into spark so that the connector just need to implement the interface and they can get a feature uh it's really reliable and it's enable more powerful feature like a catalog federation a merge delete update uh operation some kind of like a new feature like a storage uh partition join so yesterday I met friends from meta uh meta spot team actually so they talked to us and you know they don't use iceber they don't use data they have their internal catalog and they want to implement DSV2 API so they can use storage partition join right so as long as they can implement this API they can automatically get a lot of new feature in data source v2 and in DSV2 we also support aggregation push down store procedure right so it's intended for spa user and developer to work on like a custom or like you know uh of the shell share like a data uh source and is also right now the foundation of how spark and iceber been integrated.
So let's talk about like why we want to uh work on DSV2. So um how many of people here are using iceber? Okay, there are quite a bit. And how many of them are how many of you are our customer using delta? Okay, Harbor Lab. So why do we need to make a decision like which uh format is better? They both use park uh but you know they have different metadata layout and different feature right. So right now one of the idea people were talking about is that we can have some kind of translation there where we can translate the meta data but we keep the pocket file recent so that you know you can use iceber reader to read uh data uh uh table or using data reader to read iceber table but the challenging is that uh the translation although it's possible but because data is mostly on the tsv1 ice mostly on tsv2 there are a lot of different features available in different environment right and also some of the uh behavior can be different so the goal here is that we want to invest in one set of the data source API like a data source v2 so that we would be able to unify uh data and iceber in terms of the feature and then we don't have to you know um choose like you know uh which format is better because they going to provide the same feature and the same performance.

25:50 Data source features

So currently um we believe DSV2 is the future standard of the data source API in spark and now um we are working on many DSV2 feature and uh you know for like unification. So we are able to support uh both data and iceber and also those work can benefit iceber as well. Okay. So a couple feature like you know we are working on right now. So default value is one of them. So you can create a table and then uh you know with default value or for existing table you can add a default value.
So one of the use case is therefore exist existing table maybe you want to add a new column but you don't want to modify the data so you can add a default value. So all the existing like you know all data can have the default value. So it's one of the use case and I think it's available already in delta but not available in iceber. By adding this API into DSV2, we can allow iceber also having this feature. And another uh feature we are working on is check constraint.
So uh it's allow user to add constraint on the table. Uh for example, you can say or you add a constraint like a uh uh price is larger than zero for example, right? And what's the benefit of adding constraint? Uh this can help uh you know not only you know ensuring all the data insert into the table uh you know um have this constraint but also uh the constraint can be used by the query optimizer to help the query performance and we can also auto table and add a constraint and it's automatically going to trigger uh a job run to check whether existing data uh you know can validate uh with this constraint and in DSB2 we are also working on uh CDC uh which can uh used to capture the low-level changes.
So it's allow people to do like you know incremental consumption. Uh it's a basic building block for the materialized view refresh and it can also help uh to improve the efficiency of the data replication. So a lots of uh new feature can build on top of this and in 4. 1 uh CDC we print to support insert update delete checking uh and also it's going to be available for both S code and data set API and it's will be working for both streaming and batch mode as well and it's going to be a consistent CDC interface between data and iceberg in spark Okay.
So, we're going to have more feature being added in DSV2 and it's one of the active area we are working on. So, there's a talk uh yesterday uh dedicated to uh DSV2 in Apache Spa. Um but there's a recording so if you are interested in feel free to watch it offline. And uh I want to talk about a couple new data type being added into uh Spa uh 4. 1 that will be added into Spa 4. 1. So one of the um data type is a geo data type and people are asking that you know in spa we don't have native geospatial support and because of that there's no like a you know special like a you know uh um special like a geo support like optimization in the s um and this make user really difficult to handle the geo data right because for example if you want to search uh a burger near me in five mile.

29:11 Geospatial data support

How can you do it in spar code? There's no way you can easily do it and there's no easy way that you can have a meta data in park or or you know different format where you can give you the boundary of the data set in terms of the geolocation. So in spa 4. 1 we are going to address the issue and this is based on the park and iceber community. we decide to standardize how we can store geo data type across different format and including uh data.
So this unlock the opportunity for good performance because we can store the bounding uh bus statistics inside the park format where the query engine can utilize for better optimize filter uh condition and also determine which law we have to evaluate in the query. And it will be the four compatibility between iceberg and data because both of them were based on the um pocket implementation and this alignment is not only on the storage side we also need to have alignment on the engine side.
So uh p community t the iceberg community passed the vote to add a feature and spa also did that just couple weeks ago. uh laser sip in the community and we are going to support like a native geotype in spa as well uh and also spar. So this is really good milestone for crow geospatial ecosystem for many of the new use case and because of spa is able to add a new data type. So we will have a good sparkle integration. uh it can be used as a native type in spa SQL data f data set API pispar uh you know you named it and we also plan to add couple minimal set of function that you can upload on top of those new data type for example like you know um like a conversion uh between different geo type uh special query for example like you know ST bus 2D that can return a bounding box uh of uh uh geometrics or something like you know um ST bus intercept they can return if it's true if two bus overlap right like a aggregate aggregation so those are like you know basic building type building block for the geo special handling and load function will be focusing on like IO and basic geo uh indexing so for more complex use case uh people can use like you know external library uh or write their own logic uh uh to achieve the uh the functionality but we will be able to provide basic functionality and the data type is the standard uh you know uh geo data type okay so uh it's the um geo data type so it's pretty standard and people can do insert and you know use it and this is one example that you can do special join uh join like you uh two geo type.
Okay. So yeah, so there's a talk about geo and um it's yesterday. So we feel free to watch the video offline and we are also adding a new data type called time. uh is a new SQL standard and we will be support like you know hour minute uh and this a data type we are time zone uh and the basic use case is that for people to migrate from different data type uh different uh you know uh database uh uh to use it and it's a expression of the time of the day so I'm going to uh run it faster and another type uh we are adding in spa 4.

33:23 New data types and variants

0 Zero is a varant type. It's really important. So how many people using JSON over here? Yeah. So it's really slow but people need it because you know people want to have more fible schema in JSON inside spark and people sometimes have a use case where different law have different schema inside of JSON. Uh so now we have a replacement uh it's called like a variance type is in in already support in park supported in uh spa 4.

  1. So the schema can be different by different uh different law and it's really useful and really flexible data type. So uh here is a benchmark a campaign JSON and variance is eight time faster because of variance is a binary format. It's easier. You don't have to pass it uh you know pass it a JSON unlike a JSON we don't need to pass it. So it's extremely fast and in spa 4. 1 we are going to support variance shedding.

It's going to be make it even more faster because of the certain pair of the data can uh you know store in a separate column. So we will be able to support like you know min statistics uh data ping and also it require less IO and less GPU to read. kind of like you know native uh data type equivalent to the structural relational type in spar 4. 1. So super excited about that and in spa 4. 1 we are also going to support 10 table.

35:17 Temporary tables

It's a internal feature we're going to uh public review uh in datab pretty soon but we're going to open source it. So it's useful for supporting the intermediate computation result and uh also it can be automatically dropped at a session when a session is finished and it's created on demand by the user and the application. So the benefit is is self cleaning uh is session isolation and also no is required. So you don't need to have a permission to create table but you can just create a 10 table where you can put data over there.
So here is one example you create a 10 table you insert couple uh recorder into the 10 table and once the session is finished the data will be automatically cleaned up so you don't have to pay for that and CTE uh database support for a really long time. And how many people are using CTE over here? Quite a few. And how many people want to use recursive CTE? Okay, there are a couple of them. And good news is that Spark going to support recursive CTE.

36:15 Recursive CTE support

So I'm going to skip this one. So a a recursive CTE is a special type of CT where we can have some kind of repeat process uh you know defined it um um in the CTE. So recursive city have two part one is the best case and the other is the recursive part and they can be union uh to combine the data result. So uh an example is here. So here the base uh you know uh CTE query is select one. So you get select one and you have a recursive uh you know uh query and then you have a terminate termination condition where n small five.
So then you will print out one two three four five. So it's really useful when you need a tra traverse a data set uh you know a hierarchical data set and then the query uh can be implemented by recursive CTE. So before this feature many people implement uh this uh using like you know pi spark or you know uh or or like you know uh scala code and it's no longer needed. So you can just use a recursive city to implement.

37:47 SQL scripting and procedures

Okay, this is another uh okay and then she go scripting and store procedure. So uh until recently if you want to write some complicated data processing logic based on conditional statement and looping you need to use Python and now we are introducing Chico scripting and we're going to make it open source as well. So um so in the we are supporting like a compound statement and local variable. uh there's a control flow support as well.
So let's go into the example. So over here you can set up some uh local variable and you can write a condition and you do a looping over here. So it's really useful so that you don't need to use um Scala or Python code anymore. You can write a lot of control for code directly inside SQL. Okay. And store procedure. So it's another new feature we are introducing. So the motiv uh the motivation is that store procedure is a name pre-ompile SQL statement store in a uh in a uh they can accept parameter return some result and also uh call repeatedly.
So I think the benefit of doing store procedure is that you can store it as a separate uh unit in the UC or HMS and that can be secure. You can in in encapsulate your business logic inside a store procedure and is reusable. So is one example you can create a store procedure get customer order uh you can have a parameter and this call logic will be stored in UC or in HMS or other environment and can be reused. So we will be available to reuse the core in in in cach in cach and also improve performance and also in enhance better uh uh security.
Yeah. So there's a uh talk about all the shiko building block uh tomorrow on Thursday. So please attend it if you are interested. Yeah. That's it. Thank you.

Learn more about the Databricks Data and AI platform.

The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.