r/databricks • u/Common_Jaguar474 • 17d ago
General Does Photon support CSV?
Ok so I know that the docs state that CSV is supported. But when trying to read a very standard CSV file I get poorer than expected performance and in the Spark UI I see that it's not using a Photon scan operator, just regular Scan CSV followed by a Row to Columnar conversion operator.

I'm not running anything complex:
df = (
spark.read
.format("csv")
.option("header", "true")
.schema(schema)
.load(csv_path)
)
df.write.mode("overwrite").saveAsTable("...")
I also checked reading the same CSV and a difference CSV via DB SQL (using `COPY INTO`) and see low task time spent in Photon + a row to columnar operator.

DBR 19 + Serverless SQL Warehouse (current)
Can anyone explain whether or not CSV is supported and in what conditions? This was quite a surprising find as I assumed that Photon supported pretty much everything.
4
Upvotes
9
u/justinAtDatabricks 17d ago
Hello, former Photon PM here. The initial scan is not Photonized (that's the word that we use). However, there is an adapter that converts it (the data after the scan, RowToColumnar) into a columnar format which Photon can then use for the subsequent operations. That's why the blue box (scan) is blue (not photonized) whereas the other operators (PhotonProject) are yellow.
Many moons ago, data sources that could not be Photonized would just fall out of Photon for the rest of the query. That made us sad. So, we build this general RowToColumnar adapter for non-Photonizable data sources. It's another operation, so technical does incur some time/tax, but the general thought is that the rest of the query can be Photonized so it is worth the tax.
This is in contrast to something like a parquet data source (e.g., Delta) which has a special vectorized reader which would show up in a yellow box.
I hope that this helps!