Native execution engine (Spark)
| Also known as | Native engine, native accelerator, vectorized native execution |
|---|---|
| Field | Query execution performance |
| Key parts | Plan conversion from Spark physical plans, vectorized columnar operators in C++ or Rust, off-heap memory, columnar shuffle, fallback to JVM operators |
| Open source implementations | Apache Gluten (with Velox or ClickHouse), Apache DataFusion Comet, Photon (Databricks, proprietary) |
| Related | Apache Spark, Project Tungsten, Whole-stage code generation, GPU acceleration in Spark |
In Apache Spark, a native execution engine is a component that runs the physical operators of a Spark SQL or DataFrame query as vectorized, columnar code compiled to machine code (usually C++ or Rust) instead of as Java bytecode generated by Spark's whole-stage code generation in the Java virtual machine (JVM). Spark still parses, optimizes and schedules the query; the native engine replaces only the execution of the operators it supports and hands the rest back to Spark. Open source examples are Apache Gluten and Apache DataFusion Comet; Databricks Photon is a proprietary example.[1][2]
What is a native execution engine?
Apache Spark's own engine runs in the JVM. Since Spark 2.0.0, whole-stage code generation, part of Project Tungsten, compiles chains of operators into one generated Java function per stage; it is on by default through spark.sql.codegen.wholeStage in Spark 4.3.0.[3][4]
A native execution engine for Spark takes the physical plan that Spark has already chosen, converts the supported part of it into a plan for a native library, and runs that part outside the JVM on columnar batches. Apache Gluten converts the plan to Substrait and passes it through the Java Native Interface (JNI) to Velox or ClickHouse.[1] Apache DataFusion Comet serializes it in its own Protocol Buffers format and runs it with Apache DataFusion, written in Rust.[5]
How does a native engine plug into Apache Spark?
Open source native engines attach to Apache Spark through its public extension points. Both Gluten and Comet are enabled with the spark.plugins setting, turn on Spark off-heap memory (spark.memory.offHeap.enabled, which is false by default), and replace spark.shuffle.manager with a columnar shuffle manager so that data stays columnar between stages.[1][2][6] Application code, SQL and DataFrame queries do not change.
What runs natively and what falls back?
A native execution engine for Spark runs only the operators and expressions it supports. Everything else falls back to Spark's JVM operators, and the engine inserts conversions between its columnar format and Spark's row format at each boundary. Gluten calls these ColumnarToRow and RowToColumnar transitions.[1] Comet falls back at the level of a query stage: if a stage contains an unsupported operator, the stage runs in Spark.[7] Photon also falls back to the Spark runtime for operations it does not support.[8] Because each transition has a cost, the share of a plan that runs natively matters as much as the speed of the native operators.
What about Photon?
Photon is the vectorized query engine built by Databricks. Databricks describes Photon as a proprietary part of the Databricks Runtime that is not part of open source Apache Spark and is not distributed with it.[9] Databricks described it in the paper "Photon: A Fast Query Engine for Lakehouse Systems", published in the proceedings of the ACM SIGMOD 2022 conference (June 2022).[10] The Databricks documentation states that Photon replaces the JVM-based Spark SQL execution engine with a native C++ runtime for supported operations, keeps Spark's Catalyst optimizer for planning, and is compatible with Apache Spark APIs.[8]
Native engines compared
| Apache Spark (JVM, Tungsten codegen) | Apache Gluten (Velox backend) | Apache Gluten (ClickHouse backend) | Apache DataFusion Comet | Photon | |
|---|---|---|---|---|---|
| Language of the execution code | Scala and Java; generated Java code in the JVM[4] | C++ (Velox), with a Scala/Java plugin layer[1][11] | C++ (ClickHouse built as the library libch.so)[12] |
Rust (Apache DataFusion), with a Scala/Java plugin layer[5] | C++[8] |
| License / open source | Apache License 2.0[13] | Apache License 2.0 (Gluten); Velox is also Apache License 2.0[11] | Apache License 2.0 (Gluten) | Apache License 2.0[2] | Proprietary; not open source[9] |
| Foundation status | ASF top-level project[14] | ASF top-level project since 2026-02-18[15] | Same project as Gluten (Velox backend) | Sub-project of Apache DataFusion; a proposal to become top-level project "Apache Comet" is pending[16] | None (Databricks product) |
| How it is enabled | Default; spark.sql.codegen.wholeStage=true[3] |
spark.plugins=org.apache.gluten.GlutenPlugin, off-heap memory, ColumnarShuffleManager[1] |
Same plugin plus spark.gluten.sql.columnar.libpath pointing at libch.so[12] |
spark.plugins=org.apache.spark.CometPlugin, off-heap memory, CometShuffleManager[2] |
Databricks compute setting; default on SQL warehouses[8] |
| Fallback behaviour | Not applicable; operators that do not support code generation run without it | Per operator, to vanilla Spark, with ColumnarToRow and RowToColumnar transitions[1] | Same mechanism as the Velox backend[1] | Per query stage, to Spark[7] | To the Spark runtime for unsupported operations[8] |
| Primary source | Spark 4.3.0 documentation | gluten.apache.org | Gluten ClickHouse backend guide | datafusion.apache.org/comet | Databricks documentation; SIGMOD 2022 paper[10] |
What a native execution engine is not
- Not Project Tungsten. Project Tungsten made Spark's JVM execution faster with binary rows, managed memory and generated Java code; it does not leave the JVM. Native engines replace those JVM operators.[4]
- Not GPU acceleration. GPU plugins, such as the NVIDIA cuDF plugin for Apache Spark (formerly the RAPIDS Accelerator for Apache Spark), also replace Spark operators, but run them on GPUs through the cuDF libraries.[17] See GPU acceleration in Spark.
- Not a separate query engine. A native execution engine for Spark has no SQL parser or scheduler of its own in this setup; Spark plans and distributes the work.[1]
See also
- Apache Gluten
- Apache DataFusion Comet
- Velox
- Project Tungsten
- Whole-stage code generation
- GPU acceleration in Spark
References
- ↑ 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 Apache Gluten README. Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 2.0 2.1 2.2 2.3 Apache DataFusion Comet README (1.2.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 3.0 3.1 SQLConf.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 4.0 4.1 4.2 WholeStageCodegenExec.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 5.0 5.1 Comparison of Comet and Gluten. Apache DataFusion Comet.Retrieved 2026-11-23.
- ↑ Spark Configuration (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 7.0 7.1 Spark Operator Support (1.2.0). Apache DataFusion Comet.Retrieved 2026-11-23.
- ↑ 8.0 8.1 8.2 8.3 8.4 What is Photon?. Databricks.Retrieved 2026-11-23.
- ↑ 9.0 9.1 What performance features are new in Spark 4.x, and is Photon relevant to OSS Spark?. Databricks.Retrieved 2026-11-23.
- ↑ 10.0 10.1 Photon: A Fast Query Engine for Lakehouse Systems (SIGMOD '22). Association for Computing Machinery, 2022-06-10.Retrieved 2026-11-23.
- ↑ 11.0 11.1 Velox README. Meta (GitHub).Retrieved 2026-11-23.
- ↑ 12.0 12.1 ClickHouse Backend. Apache Gluten.Retrieved 2026-11-23.
- ↑ LICENSE (apache/spark v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ Apache Spark. Apache Software Foundation.Retrieved 2026-11-23.
- ↑ Apache Gluten Project Incubation Status. Apache Software Foundation.Retrieved 2026-11-23.
- ↑ Proposal to Establish Apache Comet as a Top-Level Project. Apache DataFusion Comet.Retrieved 2026-11-23.
- ↑ NVIDIA cuDF plugin for Apache Spark README. NVIDIA (GitHub).Retrieved 2026-11-23.