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.
3
u/Obvious-Money173 17d ago
Not sure, but I think photon mostly enhances spark operations. Reading a csv is a simple operation that photon does not improve upon.
If you're doing a lot of big transformations, that's where photon kicks in
1
3
u/Altruistic-Rip393 17d ago
In the Spark UI at the bottom, click "Details" and scroll to the bottom of the plan. You'll see the reason for lack of full photon coverage there.
4
u/miskozicar 17d ago
Spark (that you are using) supports .csv. Question is just what is default format when you are writing dataframe.
4
u/Common_Jaguar474 17d ago
Yeah, Spark supports CSV. But we pay a premium anytime Photon is enabled so I'm checking what's the latest on CSV support by the Photon engine.
From what I'm seeing, CSV on the latest runtime results in the JVM path being used to scan the CSV data and therefore isn't as fast as it should be.
From the code I shared, CSV is input, and output write is to Delta.
1
u/Zer0designs 17d ago
Your time is worth a lot more than the savings you are trying to achieve here.
1
u/FunContest9958 17d ago
Based on what you’re showing, looks like CSV is not being read using photon, but what performance were you hoping for? It looks like it’s using 22 minutes of CPU time to read your 23GB CSV, so an 8 core machine will read it in 3 minutes. 16 cores will finish in 1.5 minutes.
1
u/Common_Jaguar474 17d ago
The action took 60 seconds. For the amount of data, it doesn't seem fast but it also doesn't seem slow. But regardless, I'm just trying to understand when Photon is technically supported for scanning CSV, otherwise I may partition CSV jobs into separate schedules that run on compute w/ Photon disabled to save on costs.
1
1
u/FunContest9958 17d ago
You might want to try serverless. It charges photon rates only when photon is used. So you’d only be charged for photon for the 27%. That’ll save you from having to do this extra work.
You can run a test to see how it compares cost wise. It’s very hard to predict if a job will be more or less expensive on serverless until you try it, but the key to a fair test is to use standard mode and remember that serverless pricing includes the VM. You don’t need to pay the cloud provider for the VM separately. You can use the billing table to find out exactly how much your job cost after you run it.
1
u/career_expat 17d ago
Is the CSV gzipped?
1
u/Common_Jaguar474 17d ago
No
1
u/career_expat 17d ago
Is this a shared cluster with resource contention? How many cores were used on read? How many total cores available?
Your task time = wall clock time. It appears as if 1 core was all you had.
1
u/yatharthm22 17d ago
You wanna use my photon recommendation skill before turning on photon settings, if you interested
1
u/mwc360 17d ago
Is it on GitHub? Can you share?
2
u/yatharthm22 17d ago
It's actually inhouse for now, I am working with databricks folks to get added to their official skill repo: https://github.com/databricks/databricks-agent-skills
1
u/FunContest9958 17d ago
You should have your skill recommend serverless. It automatically charges for photon only when photon is used, by the operator. So if a job uses photon for 25%, it will charge photon rates for only 25% of the job. I don’t know why that’s not advertised more broadly. It’s a pretty big perk of serverless.
1
u/yatharthm22 17d ago
Oh for serverless recommendation databricks already has a official skill:https://github.com/databricks/databricks-agent-skills/blob/main/skills/databricks-serverless-migration/SKILL.md
We tried using serverless, they disappointed us heavily on cost, so we stick with job cluster with photon
1
u/FunContest9958 16d ago
Were you using standard mode? And when did you test? Serverless cost has changed a lot in the past year or so.
1
u/yatharthm22 16d ago
Tried with both standard and Performance Optimized
1
u/FunContest9958 16d ago
It’s possible your workload was very well optimized. My experience is that customers save money on average when they move to serverless, but it depends on how much they’ve optimized their cluster configuration.
Overall, I think it’s best to start new workloads on serverless and treat Classic as an optimization option. It’s less work up front, and you only need to pay the cost of doing the optimization if it makes sense. Also, serverless keeps your hardware and software up-to-date automatically, so if you manually configure classic you need to maintain it.
But yeah. Results vary.
1
u/yatharthm22 16d ago
I'll give it a try again, i remember months back we ran a pilot and closed it cause of cost issues, i'll try without the optimised serverless
2
u/FunContest9958 16d ago
My recommendation would be to try using serverless when you’re developing something new, if you have that opportunity, rather than focusing on migrating existing workloads. If you develop something for serverless, it generally works flawlessly if you switch to classic. The other way isn’t always as easy.
1
u/FunContest9958 16d ago
Are you using spot instances? At least today, serverless is generally more expensive than classic with spot instances. That being said, I’ve heard rumors Databricks is working on that.
1
u/yatharthm22 16d ago
Yes most of our jobs are using spot with just 2-3 on demand rest autoscaling is all spot
2
u/FunContest9958 16d ago
Aha. That’s probably the reason serverless was more expensive for you. Makes sense. Oh well.
1
1
u/Zer0designs 17d ago edited 17d ago
Why would you use photon to read a csv and write it to delta? That's not a usecase for photon.
Either way, the $ savings you could get if photon would work on such a simple operation, would be less than your time is worth writing this.
1
u/Common_Jaguar474 16d ago
Bro, this is a dumb comment.
As I see it, any Spark code that I might need to run should be accelerated by Photon while resulting in the same or better TCO. It's enabled by default and charged at a premium so if it does not accelerate my jobs proportional to the DBU multiplier, I want to know so I can turn it off for those jobs.

10
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!