Comment
Databricks Employee
Databricks Employee

hi @Erik thanks, good question, its batch duration too. Query planning happens on each batch and generates fresh physical plan.

The optimizer can’t fully eliminate the overhead of many chained withColumn calls because each call adds a new projection and attribute aliases that must be preserved for correctness;  Catalyst must traverse and optimize a larger tree every time, which increases planning cost. 

Using withColumns (or a single select) applies all transformations in one projection, keeping the plan shallow and reducing per‑query planning overhead.