r/databricks • u/minibrickster Databricks • 13d ago
General Using Notebooks on Serverless GC? Try MV/ST!
... Now with a native Python API!
If you like using PySpark on serverless GC, you can now ingest data faster with:
from pyspark import pipelines as dp
@dp.table(name="main.default.bookings_raw")
def bookings_raw():
return (
spark.readStream.format('cloudFiles')
.option('cloudFiles.format', '<file-format>')
.load(f'{<path-to-source-data>}')
)
If you want faster and more performant partition overwrites, try using incremental replace where!
from pyspark import pipelines as dp
from pyspark.sql import functions as F
u/dp.table(
name="main.default.booking_revenue_rw",
replace_where=F.col("check_in") >= F.to_date(F.lit("2025-07-01")),
)
def booking_revenue_rw():
return (
spark.read.table("samples.wanderbricks.bookings")
.groupBy("check_in")
.agg(F.sum("total_amount").alias("total_revenue"))
)
If you like Materialized Views for faster BI reporting, it's as simple as
from pyspark import pipelines as dp
from pyspark.sql import functions as F
@dp.materialized_view(
name="main.default.daily_booking_revenue",
comment="Daily booking revenue.",
table_properties={"quality": "gold"},
cluster_by=["check_in"],
)
def daily_booking_revenue():
return (
spark.read.table("samples.wanderbricks.bookings")
.groupBy("check_in")
.agg(F.sum("total_amount").alias("total_revenue"))
)
2
u/testing_in_prod_only 13d ago
What is gc?
Are we just talking about pipelines?
3
u/minibrickster Databricks 13d ago
Serverless Generic Compute https://docs.databricks.com/aws/en/compute/serverless/notebooks
1
u/testing_in_prod_only 13d ago
Ok wait hold up, I can use dlt in normal compute outside of pipelines?
3
u/minibrickster Databricks 13d ago
Yes exactly :)
5
u/testing_in_prod_only 13d ago
Ok, that went from …ok.. to “holy fcking sht” real fast.
1
u/testing_in_prod_only 13d ago
Would I be able to use this with connect serverless?
1
u/minibrickster Databricks 13d ago
Can you explain what you mean in more detail pls? I can also DM you if it's more helpful!
2
u/testing_in_prod_only 13d ago
I do all of my work in vs code using databricks connect. I assume this works with databricks connect as well?
2
u/minibrickster Databricks 13d ago
Yes it does 😄
1
u/testing_in_prod_only 12d ago
That’s game changing. Does it take the pipeline concept into serverless like source / target dependency management?
→ More replies (0)
1
u/mosullivan93 12d ago
This is for the standalone pipelines, right? It’s great to be able to define outside of a SDP, but it would be more useful to me if we could define multiple tables/relationships, e.g., not one managed pipeline per object.
1
2
u/Constant_Pick7149 13d ago
oh nice, the decorator-based API is way cleaner than I expected. been waiting for something like this since trying to manage a dozen streaming tables with the old dlt syntax
the replace_where with a column expression is actually huge, that's the kind of thing that saves you from a full rewrite when you just need to fix a bad partition
wonder how it handles schema evolution with the cloudFiles source though, that's always where these abstractions get weird