In my early days working with Microsoft Fabric, I assumed something that seemed obvious: "It ran in a Spark notebook, so Spark must have executed it." It turned out to be only partly true. The problem appeared when I looked closely at Warehouse queries launched from notebooks. A Spark notebook tells where a request started. It does not always tell me which engine did the underlying work.
The query language is not the execution engine
Take this for example:
result = spark.sql("""
SELECT
CustomerId,
SUM(SalesAmount) AS TotalSales
FROM Sales
GROUP BY CustomerId
""")Here, Spark SQL handles the statement. It parses the SQL, builds a logical plan, optimises it, produces a physical plan, and asks Spark executors to do the work.

In this case, it is fair to say that Spark executed the query. Now look at a different operation from the same notebook:
df = spark.read.synapsesql(
"SalesWarehouse.dbo.FactSales"
)The call still starts in a Spark notebook, and the result is still a Spark DataFrame. But the execution boundary has changed.
The synapsesql connector lets Spark read from a Fabric Warehouse or the SQL analytics endpoint of a Lakehouse. Microsoft’s documentation is clear that when a custom or pass-through query is supplied, that query is passed to the SQL engine and the result is returned to Spark.
So the flow is closer to this:

A DataFrame at the end does not prove that Spark performed the original database query. It only tells me the format in which Spark received the result.
A notebook is an execution surface, not necessarily an engine
The mental shift that helped me was this: a notebook is where I submit code. It is not a guarantee that every operation is executed by the notebook’s local engine.
We already accept this outside Fabric.
df = pandas.read_sql(query, sql_connection)
Nobody would normally say that pandas executed the joins and aggregations in the database. The database engine runs the SQL; pandas receives the rows.
The same principle applies when Spark talks to a Fabric Warehouse.
Spark can be involved in several different ways:
- It may execute the entire workload.
- It may ask another engine to execute a query.
- It may receive data from another engine and continue processing it.
- Some filtering or projection may be pushed down to the remote engine, where the connector and query support it.
- It may then perform further transformations on the returned result.
That is why “I ran it from Spark” and “Spark executed all of it” are not the same statement.
Same SQL, different execution paths
The SQL text alone does not identify the engine either.
SELECT Region, SUM(SalesAmount)
FROM FactSales
GROUP BY Region;I could submit that same query through several routes:
- spark.sql() against a table resolved by Spark
- the Fabric Warehouse query editor
- a SQL client connected to a Warehouse endpoint
- a PowerBI DirectQuery connection
- a Spark connector using a pass-through query
The text looks identical. The runtime behaviour may not be.
Path 1: Spark SQL
spark.sql("""
SELECT Region, SUM(SalesAmount)
FROM FactSales
GROUP BY Region
""")If FactSales resolves to a table available to Spark, Spark builds and executes the plan.
Spark -> Delta files in OneLake
Path 2: Fabric Warehouse
SELECT Region, SUM(SalesAmount)
FROM FactSales
GROUP BY Region;Submitted through the Warehouse endpoint, the Warehouse SQL engine parses, optimises, and executes the statement.
Warehouse SQL engine -> Warehouse managed data in OneLake
Fabric Warehouse manages its own physical table layout and maintenance behaviour. Lakehouse tables are commonly maintained through Spark or user-managed processes. That difference is another clue that Warehouse is not simply a Spark interface.
Path 3: Spark calling the Warehouse
df = (
spark.read
.option("query", warehouse_query)
.synapsesql("SalesWarehouse")
)The notebook initiates the request, but the Warehouse SQL engine executes the pass-through query. Spark receives the result and may then do further work on it.
Warehouse SQL engine -> Filtered or aggregated result -> Spark DataFrame -> Additional Spark transformations
This is not SQL being quietly converted into Spark code. It is one engine invoking another, then continuing the workload.
Small example that made this clear
I once reviewed a notebook that read a large Warehouse fact table into Spark and then filtered it by date:
df = spark.read.synapsesql("SalesWarehouse.dbo.FactSales")
df_filtered = df.filter(df.OrderDate >= "2024-01-01")The notebook ran, but it took longer than expected. The issue was not Spark itself. The notebook was bringing the full table into Spark first, and only then applying the date filter. A better approach was to push the filter into the SQL query:
query = """
SELECT *
FROM dbo.FactSales
WHERE OrderDate >= '2024-01-01'
"""
df = (
spark.read
.option("query", query)
.synapsesql("SalesWarehouse")
)In this version, the Warehouse SQL engine handles the filtering and returns only the required rows to Spark. Spark still receives a DataFrame, but it has far less data to process. That was the moment the distinction became practical for me: the notebook had not changed, but the execution boundary had. The filtered query returned about 2 million rows instead of 85 million, and the notebook completed noticeably faster.

A quick way to tell the paths apart
When reviewing a notebook, I now look at the call pattern before assuming anything about execution. The table below is deliberately simplified, but it is useful as a first check.
Call pattern | Likely execution path | What to check |
spark.sql() against a Spark-resolved Delta table | Spark SQL builds and executes the plan | Spark UI, job details and physical plan |
spark.read.synapsesql(“warehouse.schema.table”) | Read through the Warehouse or SQL analytics endpoint; result returns to Spark | Endpoint permissions, object type, and volume of data returned |
spark.read.synapsesql() with option(“query”, ...) | Custom/pass-through query is passed to the SQL engine | SQL query plan, filters/aggregations in the query, and rows returned to Spark |
Warehouse query editor | Warehouse SQL engine | Warehouse query insights and query plan |
Why the confusion is common
Spark is highly visible
In a notebook, I can see the Spark session, cells, DataFrames and job information. The remote SQL engine is much less visible. It is natural to credit Spark with the whole operation.
The result is a DataFrame
Once Warehouse data appears as a DataFrame, it feels as though Spark must have read and processed the source table itself. But a DataFrame describes data available to Spark. It does not prove where the upstream calculation happened.
SQL spans several engines
SQL is a language and an interface, not one execution technology. Spark SQL, the Warehouse SQL engine and a relational database can accept similar SQL while using different optimisers, plans, runtimes, and storage-access patterns.
Fabric hides some integration detail
The Fabric Spark connector is preinstalled and makes cross-workload access feel straightforward. That is helpful for developers, but convenience can obscure the architectural boundary.
A more accurate Fabric mental model
It is tempting to picture Fabric like this: Every workload -> Spark -> OneLake
But actually it’s not. A more useful picture is this:

The key point is simple: shared storage does not imply shared compute.
Delta tables in OneLake can be consumed by Spark, SQL analytics endpoints, Warehouse-related experiences, and Power BI Direct Lake. The workload that owns the table layout and the engine that consumes the table both affect performance and operations.
OneLake gives the engines a common data foundation. It does not turn them into one universal engine.
Why this matters in practice
Performance
If a large Warehouse table is needed only for a small filtered subset, it can make sense to filter or aggregate in the SQL query before returning data to Spark. That can reduce unnecessary data movement.
But pushdown should be verified rather than assumed. The supported behaviour depends on the connector, query shape, and operation. I would confirm it using the query plan, monitoring information, row counts, and timings rather than relying on the code alone.
Security
When Spark accesses a Warehouse through the SQL endpoint, SQL-layer security such as object-level, row-level, and column-level controls can apply, subject to the permissions configured for the calling identity.
Reading underlying files through another route is not automatically equivalent to querying through that secured endpoint. The access path matters.
Troubleshooting
When performance is poor, “Why is Spark slow?” is often the wrong first question.
Better questions are:
- Which engine produced the expensive operation?
- Was filtering or aggregation pushed down to the SQL engine?
- How many rows were returned to Spark?
- Did Spark then perform further joins or aggregations?
- Was data read directly from Delta files?
- Where exactly did the execution boundary occur?
Without those answers, tuning becomes guesswork.
Capacity planning
A Spark transformation, a Warehouse aggregation, and a high-concurrency BI query may all consume Fabric capacity, but they do not necessarily behave in the same way. Treating every workload as “Spark” hides why the platform has specialised engines in the first place.
Four questions I now ask When looking at any Fabric workload:
1. Where was the request submitted?
This identifies the interaction surface, not necessarily the execution engine.
- Spark notebook
- Warehouse query editor
- SQL client
- Data pipeline
- Power BI report
2. Which API or method was used?
For example, spark.sql() usually points to Spark SQL execution. spark.read.synapsesql() points to communication with a Warehouse or SQL analytics endpoint. A custom query option is the strongest signal that the SQL engine may execute the query.
3. Where does the object live?
- Lakehouse Delta table
- Warehouse table
- Warehouse view
- SQL analytics endpoint object
- External database object
4. Where was the expensive work performed?
I look for the engine that handled the costly operations:
- Scans
- Filters
- Joins
- Aggregations
- Security evaluation
- Data movement
That engine is doing the meaningful computational work, even if another surface initiated the request.
What I wish I had understood earlier
A useful mental model is:
When SQL is submitted through spark.sql() against data resolved by Spark, Spark parses and executes the query. When a Spark notebook sends a custom or pass-through query to a Fabric Warehouse through the connector, the Warehouse SQL engine executes that query and returns the result to Spark.
Sometimes both engines participate:
SQL engine performs the initial query -> Spark receives the result -> Spark performs subsequent processing
The notebook did not change engines. The workload crossed an engine boundary. That is the part many of us overlook. Fabric is not one compute engine with several user interfaces. It is a set of specialised analytical engines working over a shared data foundation. Once I separate where code was written, which language was used, where the data lives, and which engine executed the work, the architecture becomes much easier to reason about.
So when somebody says:
It ran in a Spark notebook, so Spark executed it.
My next question is:
Which operation, and where did that operation actually execute?
References
Article Topics & Tags