Piezīmes
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt pierakstīties vai mainīt direktorijus.
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt mainīt direktorijus.
The native execution engine is a groundbreaking enhancement for Apache Spark job executions in Microsoft Fabric. This vectorized engine optimizes the performance and efficiency of your Spark queries by running them directly on your lakehouse infrastructure. The engine's seamless integration means it requires no code modifications and avoids vendor lock-in. It supports Apache Spark APIs and is compatible with Runtime 2.0 (Apache Spark 4.1) and Runtime 1.3 (Apache Spark 3.5), and works with Parquet, Delta, CSV, and JSON formats. Regardless of your data's location within OneLake, or if you access data via shortcuts, the native execution engine maximizes efficiency and performance.
The native execution engine significantly elevates query performance while minimizing operational costs. Actual results vary by workload characteristics and configuration. The engine is adept at managing a wide array of data processing scenarios, ranging from routine data ingestion, batch jobs, and ETL (extract, transform, load) tasks, to complex data science analytics and responsive interactive queries. Users benefit from accelerated processing times, heightened throughput, and optimized resource utilization.
The Native Execution Engine is based on two key OSS components: Velox, a C++ database acceleration library introduced by Meta, and Apache Gluten (incubating), a middle layer responsible for offloading JVM-based SQL engines’ execution to native engines introduced by Intel.
Supported operators are offloaded from JVM-based Spark to a vectorized C++ execution path, providing columnar, SIMD-accelerated processing with native support for Parquet and Delta formats. The native engine preserves key Fabric Spark query optimizations, including adaptive query execution (AQE), cost-based rewrites, column pruning, and predicate pushdown, so these optimizer behaviors remain fully active when operators are offloaded. The engine also supports parallel Delta snapshot loading and accelerates operations that benefit from Z-ordering and Liquid Clustering on Delta tables, providing further performance gains for organized data layouts.
When to use the native execution engine
The native execution engine offers a solution for running queries on large-scale data sets; it optimizes performance by using the native capabilities of underlying data sources and minimizing the overhead typically associated with data movement and serialization in traditional Spark environments. The engine supports various operators and data types, including rollup hash aggregate, broadcast nested loop join (BNLJ), and precise timestamp formats. However, to fully benefit from the engine's capabilities, you should consider its optimal use cases:
- The engine is effective when working with data in Parquet and Delta formats, which it can process natively and efficiently.
- Queries that involve intricate transformations and aggregations benefit significantly from the columnar processing and vectorization capabilities of the engine.
- Performance enhancement is most notable in scenarios where the queries don't trigger the fallback mechanism by avoiding unsupported features or expressions.
- The engine is well-suited for queries that are computationally intensive, rather than simple or I/O-bound.
For information on the operators and functions supported by the native execution engine, see Apache Gluten documentation.
Enable the native execution engine
The native execution engine is generally available. The following procedures show how to enable it for notebooks, Spark job definitions, and entire environments.
Important
Use Runtime 2.0 (Apache Spark 4.1, Delta Lake 4.2) with the native execution engine for supported workloads to benefit from the latest enhancements, performance improvements, and a longer support window. The engine also supports Runtime 1.3 (Apache Spark 3.5, Delta Lake 3.2), which is in the end of support announced (EOSA) stage. If you're using Runtime 1.3, validate workload compatibility and plan your migration to Runtime 2.0.
Enable at the environment level
To ensure uniform performance enhancement, enable the native execution engine across all jobs and notebooks associated with your environment:
Navigate to the workspace containing your environment and select the environment. If you don't have environment created, see Create, configure, and use an environment in Fabric.
Under Spark compute select Acceleration.
Check the box labeled Enable native execution engine.
Save and Publish the changes.
When enabled at the environment level, all subsequent jobs and notebooks inherit the setting. This inheritance ensures that any new sessions or resources created in the environment automatically benefit from the enhanced execution capabilities.
Important
Previously, the native execution engine was enabled through Spark settings within the environment configuration. The native execution engine can now be enabled more easily using a toggle in the Acceleration tab of the environment settings. To continue using it, go to the Acceleration tab and turn on the toggle. You can also enable it via Spark properties if preferred.
Enable for a notebook or Spark job definition
You can enable the native execution engine for a single notebook or Spark job definition without changing the environment-level setting.
Notebook
Run the following command in the first code cell, before starting the Spark session:
%%configure
{
"conf": {
"spark.native.enabled": "true"
}
}
If the session is already running, restart it to apply the session configuration. For details, see Spark session configuration magic command.
Spark job definition
In the Spark job definition, open Spark Compute and select Add to add the Spark
configuration spark.native.enabled with the value true. Save the change before running
the job. Don't include %%configure in the job's execution script; it's a notebook magic
command. For details, see Options to customize Spark job definitions.
Control on the query level
You can disable the native execution engine for specific queries, for example, when
troubleshooting a failure or using operators that aren't supported (see limitations).
Before running the query, set spark.native.enabled to false as shown in the following
examples. The setting remains in effect until you change it back.
%%sql
SET spark.native.enabled=FALSE;
After running the query, set spark.native.enabled back to true to re-enable native
execution for subsequent queries:
%%sql
SET spark.native.enabled=TRUE;
Identify operations executed by the engine
There are several methods to determine if an operator in your Apache Spark job was processed using the native execution engine.
Spark UI and Spark history server
Access the Spark UI or Spark history server to locate the query you need to inspect. To access the Spark web UI, navigate to your Spark job definition and run it. From the Runs tab, select the ... next to the Application name and select Open Spark web UI. You can also access the Spark UI from the Monitor tab in the workspace. Select the notebook or pipeline, from the monitoring page, there's a direct link to the Spark UI for active jobs.
In the query plan displayed within the Spark UI interface, look for any node names that end with the suffix Transformer, *NativeFileScan, or VeloxColumnarToRowExec. The suffix indicates that the native execution engine executed the operation. For instance, nodes might be labeled as RollUpHashAggregateTransformer, ProjectExecTransformer, BroadcastHashJoinExecTransformer, ShuffledHashJoinExecTransformer, or BroadcastNestedLoopJoinExecTransformer. For CSV data sources, native scans may appear as native file scan or transformer nodes in the Spark UI, similar to Parquet and Delta scan nodes.
DataFrame explain
Alternatively, you can execute the df.explain() command in your notebook to view the execution plan. Within the output, look for the same Transformer, *NativeFileScan, or VeloxColumnarToRowExec suffixes. This method provides a quick way to confirm whether specific operations are being handled by the native execution engine.
Fabric Spark Advisor alerts
Fabric Spark Advisor provides real-time fallback visibility during notebook cell execution. When an operator or plan segment falls back to JVM-based Spark instead of the native path, Advisor surfaces an alert directly in the notebook cell output, helping you quickly identify unsupported operators or configurations without leaving the notebook. You can use these alerts to diagnose when native offload isn't applied and to decide whether to adjust your query or configuration.
Fallback mechanism
In some instances, the native execution engine might not be able to execute a query due to reasons such as unsupported features. In these cases, the operation falls back to the traditional Spark engine. This automatic fallback mechanism ensures that there's no interruption to your workflow.
Monitor Queries and DataFrames executed by the engine
To better understand how the Native Execution engine is applied to SQL queries and DataFrame operations, and to drill down to the stage and operator levels, you can refer to the Spark UI and Spark History Server for more detailed information about the native engine execution.
Native Execution Engine Tab
You can navigate to the new 'Gluten SQL / DataFrame' tab to view the Gluten build information and query execution details. The Queries table provides insights into the number of nodes running on the Native engine and those falling back to the JVM for each query.
Query Execution Graph
You can also select on the query description for the Apache Spark query execution plan visualization. The execution graph provides native execution details across stages and their respective operations. Background colors differentiate the execution engines: green represents the Native Execution Engine, while light blue indicates that the operation is running on the default JVM Engine.
Limitations
While the native execution engine (NEE) in Fabric significantly boosts performance for Apache Spark jobs, it currently has the following limitations. Several correctness-related items that applied to Runtime 1.3 (Apache Spark 3.5) are resolved in Runtime 2.0 (Apache Spark 4.1); each item notes the runtime it applies to.
Existing limitations
Structured Streaming (all runtimes): The native execution engine doesn't currently support Structured Streaming. Use the standard Spark JVM engine for streaming workloads.
XML (all runtimes): The native execution engine doesn't accelerate queries against XML files. These queries fall back to the standard Spark JVM engine.
ANSI mode (all runtimes): The native execution engine doesn't currently support ANSI SQL mode. Use the standard Spark JVM engine for workloads that require ANSI SQL mode.
Storage access through managed private endpoints (all runtimes): The native execution engine doesn't currently support storage access through managed private endpoints. Use the standard Spark JVM engine for workloads that require this access.
Python libraries and nested complex types: Libraries that require arbitrary Python object serialization and certain operations on deeply nested complex types (for example, arrays of maps of structs) might fall back to the Spark JVM engine. For supported capabilities, see Python UDFs, Scala UDFs, and complex data types in native execution engine.
Date filter type mismatches (all runtimes): To benefit from the native execution engine's acceleration, ensure that both sides of a date comparison match in data type. For example, instead of comparing a
DATETIMEcolumn with a string literal, cast it explicitly as shown:CAST(order_date AS DATE) = DATE '2024-05-20'
Other considerations and limitations
Note
The decimal-casting, timezone, round(), map() duplicate-key, and collect_list()/collect_set() items in this section apply to Runtime 1.3 (Apache Spark 3.5) and are resolved in Runtime 2.0 (Apache Spark 4.1). They're retained for users still running on Runtime 1.3.
Decimal to Float casting mismatch (Runtime 1.3; resolved in Runtime 2.0): When casting from
DECIMALtoFLOAT, Spark preserves precision by converting to a string and parsing it. On Runtime 1.3, NEE (via Velox) performs a direct cast from the internalint128_trepresentation, which can result in rounding discrepancies.Timezone configuration errors (Runtime 1.3; resolved in Runtime 2.0): On Runtime 1.3, setting an unrecognized timezone in Spark causes the job to fail under NEE, whereas Spark JVM handles it gracefully. For example:
{ "spark.sql.session.timeZone": "-08:00" }Inconsistent rounding behavior (Runtime 1.3; resolved in Runtime 2.0): On Runtime 1.3, the
round()function behaves differently in NEE due to reliance onstd::round, which doesn't replicate Spark’s rounding logic. This difference can lead to numeric inconsistencies in rounding results.Missing duplicate key check in
map()function (Runtime 1.3; resolved in Runtime 2.0): Whenspark.sql.mapKeyDedupPolicyis set to EXCEPTION, Spark throws an error for duplicate keys. On Runtime 1.3, NEE skips this check and allows the query to succeed incorrectly. On Runtime 2.0, NEE raisesDUPLICATED_MAP_KEYconsistently with JVM Spark.
Example:SELECT map(1, 'a', 1, 'b'); -- Should fail with duplicate keysOrder variance in
collect_list()with sorting (Runtime 1.3; resolved in Runtime 2.0): When usingDISTRIBUTE BYandSORT BY, Spark preserves the element order incollect_list(). On Runtime 1.3, NEE might return values in a different order due to shuffle differences, which can result in mismatched expectations for ordering-sensitive logic.Intermediate type mismatch for
collect_list()/collect_set()(Runtime 1.3; resolved in Runtime 2.0): On Runtime 1.3, Spark usesBINARYas the intermediate type for these aggregations, whereas NEE usesARRAY. This mismatch might lead to compatibility issues during query planning or execution.