Photon is Databricks' native vectorized engine — a from-scratch reimplementation of Apache Spark's execution layer in C++. It maintains compatibility with the traditional JVM-based Spark engine while applying CPU-level optimizations (SIMD, columnar batch processing) to deliver significant speedups, especially for SQL queries, DataFrame operations, and Delta Lake I/O.
This article covers which workloads Photon supports and does not support, how automatic JVM fallback behaves, how to enable Photon, and a cost comparison across Classic, Photon, and Serverless.
Traditional Spark runs as Java bytecode on the JVM. Photon replaces that execution layer with C++ and adds the following optimizations:
Thanks to these optimizations, Photon can deliver roughly 2-8x speedups over the traditional Spark engine, especially for CPU-bound workloads (heavy JOINs, aggregations, sorts, and filtering).
Photon delivers speedups on the workloads below. Most Spark SQL and DataFrame API operations are covered by Photon.
| Workload | Photon support | Notes |
|---|---|---|
| Spark SQL (SELECT/JOIN/WHERE/GROUP BY) | Supported | The area with the largest speedup |
| DataFrame API (filter/groupBy/join/agg) | Supported | Same optimizations as SQL |
| Delta Lake reads (Scan) | Supported | Accelerated Parquet decoding |
| Delta Lake writes (INSERT/MERGE/UPDATE/DELETE) | Supported | Write path also runs on Photon |
| Parquet file read/write | Supported | Native Parquet reader |
| JOIN (Hash Join / Sort Merge Join) | Supported | Substantial impact on large JOINs |
| Aggregations (SUM/COUNT/AVG/MIN/MAX) | Supported | Fast thanks to vectorization |
| Sort (ORDER BY) | Supported | Effective for sorting large datasets |
| Window functions | Supported | ROW_NUMBER, RANK, etc. |
| Structured Streaming (micro-batch) | Supported | The batch-processing portion is accelerated by Photon |
The workloads below do not run on Photon and automatically fall back to the JVM-based Spark engine. Even on Photon-enabled clusters, this processing runs as classic Spark.
| Workload | Photon support | Reason / Notes |
|---|---|---|
| RDD API | Not supported | Low-level APIs are outside Photon's optimization scope |
| Python UDFs (standard UDFs) | Not supported | Runs in a Python process, outside the C++ engine |
| Scala/Java UDF | Not supported | Custom code running on the JVM is outside Photon's scope |
| Pandas UDF (Arrow-optimized UDF) | Not supported | Executes in a Python process |
| Structured Streaming stateful ops (mapGroupsWithState, etc.) | Not supported | Custom state management is handled on the JVM side |
| MLlib / SparkML | Not supported | ML-specific code paths are outside Photon |
| GraphX | Not supported | Graph processing runs on the JVM |
| CSV/JSON file reads (partial) | Partial support | Less benefit than with Parquet or Delta |
Running an unsupported operation on a Photon-enabled cluster does not raise an error. Only that operation falls back to the JVM-based Spark engine, while the remaining Photon-supported operations continue to run on Photon.
# 例:Photon対応クラスタでUDFを含むクエリを実行
from pyspark.sql.functions import udf
from pyspark.sql.types import StringType
# このUDFはJVMフォールバックで実行される
@udf(returnType=StringType())
def custom_transform(value):
return value.upper() + "_PROCESSED"
# filterとgroupByはPhotonで実行、UDF部分のみJVMで実行
result = (
spark.read.format("delta").load("/mnt/silver/orders")
.filter("amount > 100") # Photon
.withColumn("label", custom_transform("region")) # JVM fallback
.groupBy("label").sum("amount") # Photon
)
result.display()When you inspect the query plan in the Spark UI, operators that ran on Photon carry a 'Photon' prefix (PhotonScan, PhotonHashAggregate, etc.). Operators without that prefix have fallen back to the JVM.
You can enable Photon in any of the following ways. Setting it at cluster creation time is the most common approach.
// Cluster Policy でPhotonを強制する例
{
"runtime_engine": {
"type": "fixed",
"value": "PHOTON"
},
"spark_version": {
"type": "regex",
"pattern": "15\\.4\\.x-photon-scala.*",
"defaultValue": "15.4.x-photon-scala2.12"
}
}On Serverless SQL Warehouse, Photon is enabled by default — you get Photon's speedups with no additional configuration.
Deciding whether to adopt Photon requires looking at both the DBU rate and the runtime. Here's an overview of the cost profile of each compute option (actual rates vary by cloud provider and region).
| Compute type | DBU rate | Processing speed | Total cost tendency | Best-fit use cases |
|---|---|---|---|---|
| Classic Runtime (JVM) | Baseline | Baseline | Gets expensive when runtimes are long | Heavy UDF usage, RDD processing, ML |
| Photon Runtime | Higher than Classic | 2-8x faster (supported workloads) | Speedups can reduce total DBU consumption | SQL/DataFrame-centric ETL, large JOINs and aggregations |
| Serverless SQL Warehouse | Highest | Photon + instant start | Zero idle cost, but the highest unit rate | BI queries, dashboards, ad-hoc analytics |
The most reliable way to evaluate Photon's ROI is to run the same workload on Classic and Photon and compare runtime and DBU consumption. For ETL jobs dominated by JOINs, aggregations, and sorts, the shorter runtime typically outweighs Photon's higher unit price.
Data Engineer Associate
問題 1
You run a Spark SQL query that includes a Python custom UDF on a cluster using a Photon-enabled Databricks Runtime. Which describes the correct behavior?
正解: C
When Photon detects an unsupported operation (including custom UDFs), only that operation falls back to the JVM-based Spark engine. The query as a whole does not error, and other Photon-supported operations (filter, groupBy, JOIN, etc.) continue to run on Photon.
Does Photon accelerate custom UDFs?
No. Photon is a vectorized engine implemented in C++, and custom UDFs written in Python or Scala do not run on Photon. UDF processing automatically falls back to the JVM-based Spark engine. To get Photon's benefits, rewrite UDF logic using Spark SQL built-in functions or the DataFrame API wherever possible.
Does enabling Photon increase costs?
Photon-enabled DBR (Databricks Runtime) has a higher per-DBU price than Classic. However, because Photon often shortens query runtime dramatically, total DBU consumption drops and the net result is usually a cost reduction. For workloads heavy in JOINs, aggregations, and sorts, the performance gains typically outweigh the higher unit price.
How can I tell which queries are not using Photon?
Check the query execution plan in the Spark UI and look for a 'Photon' prefix on each operator. Operators such as PhotonScan or PhotonGroupingAgg run on Photon. Operators without that prefix have fallen back to the JVM. You can also tune Photon's coverage with settings like spark.databricks.photon.allDataSources.enabled.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)
Complete guide to all 7 Databricks certifications — Data Eng...
Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)
Every Databricks certification ranked by difficulty, with st...
Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)
How to pass Databricks certifications efficiently. Official ...
Databricks Data Engineer Associate: Complete Guide (2026)
Domain-by-domain breakdown of the Databricks Certified Data ...
Databricks Data Engineer Professional: Complete Guide (2026)
Tactics for the Databricks Certified Data Engineer Professio...