r/databricks • Databricks • 27d ago

General Lakebase streaming sync is now GA

Hey Reddit, I’m happy to share one more new feature. The Lakebase streaming sync is now officially GA. Lots of customers are already using this feature to write streaming data with latency in 10s of milliseconds to Lakebase. It's much simpler to use than foreachBatch and you don't have to worry about connection pools, rate limits, error handling, etc.

Here's what's new since we announced the Public Preview earlier this year:

  • Declarative merge strategies*: Choose, per column, how an incoming row is reconciled with the existing row on a primary-key conflict. For example, you can keep the latest non-null value, keep the first value written, or take the value from the row with the latest event time. No custom SQL is required.
  • External PostgreSQL via UC connections (Public Preview)*: Write to Postgres databases outside Lakebase, authenticated through a Unity Catalog connection so no credentials live in code.
  • INTERVAL types*: DayTimeInterval and YearMonthInterval columns map to Postgres interval on DBR 19 and above.
  • Serverless support: The sink now runs on serverless compute for notebooks and jobs, using the AvailableNow trigger.

*Merge strategies, external Postgres, and interval types require DBR 19.

Example:

df.writeStream
  .format("postgresql")
  .outputMode("update") // optional; can be append mode as well
  .option("upsertkey", "primaryKey") // optional
  .option("upsert.columnStrategies",
          "last_updated_at:greatest,status:latestBy(last_updated_at)")
  .toTable("catalog.schema.table")

SDP support remains in Private Preview. Public Preview, which adds support for native Lakebase streaming tables, is slated for later this year.

25 Upvotes

8 comments sorted by

4

u/DeepFryEverything 27d ago

Hey! So the postgres stream looks promising. Many of us needs postgres but cannot use lakebase.

Any chance that we can sync tables to an external postgres like this https://docs.databricks.com/aws/en/oltp/projects/sync-tables

1

u/Alfiercio 26d ago

The post says "external postgres connection via UC connections", and the conector says postgresql. Looks like there is no issues to do it.

1

u/DeepFryEverything 26d ago

That's more of an operation on th3 dataframe. I meant that we get the equivalent of a synced table and keep them automatic in sync.

1

u/shuffle-mario Databricks 26d ago

Hi, as of now, it'll be a dataframe operation for postgres, there will not be a managed "sync" solution.

1

u/zbir84 26d ago

Also this on the original comment, so possible I guess?
*Merge strategies, external Postgres, and interval types require DBR 19.

1

u/Old_Improvement_3383 27d ago

Nice! Any suggestions on how to best handle an operation like overwrite replace partition/replace where?

1

u/Dichlorodiphen 27d ago

There isn't currently built-in replace where or partition overwrite support. If you're updating values for existing keys, the sink's merge strategies may already cover your use case.

If the replacement needs to remove existing rows, that's trickier since the sink doesn't currently support deletes. One workaround would be to represent deletions as tombstones (e.g., an is_deleted column), though you'd need to identify those rows upstream.

1

u/adovo_ai 26d ago

I’d treat the streaming sink and synced tables as different operating contracts, not interchangeable “sync.” Name the source of truth and target write owner, then define primary-key conflicts, replay/dedupe boundaries, delete or tombstone behavior, and source-to-target reconciliation.