Databricks Blog (Postgres / Lakebase)·· 10d agoFeatured
Databricks Makes Lakebase Postgres Spark Streaming Sink Generally Available
Announcing General Availability of native Lakebase Postgres sink for Spark Structured Streaming
Key Takeaway
Databricks made the native Lakebase Postgres sink for Apache Spark Structured Streaming generally available, with built-in batching, connection pooling, retries, deduplication, and upserts.
Why It Matters
Databricks makes the Lakebase Postgres sink generally available, removing custom batching, retry, and upsert infrastructure while reporting latency at sustained streaming scale.
Technical Breakdown · Distilled from the original source
Runtime and connection paths
- The native sink is generally available on Databricks Runtime 18 LTS and above and supports both micro-batch processing and Real-Time Mode. The
RealTimeandProcessingTimetriggers run on classic compute; serverless usesTrigger.AvailableNow. Apache Spark Declarative Pipelines does not support the sink. - For a Unity Catalog-registered Lakebase table, pass the fully qualified
catalog.schema.tableto.toTable(). The connector authenticates as the running user or service principal and creates the table if it does not exist. For an unregistered Lakebase table, useformat("postgresql")with the endpoint anddbtable.
Conflict handling and write tuning
upsertkeykeeps one row per key. Declarative merge strategies on DBR 19 and above can retain the latest non-null value or take the value from the newer event without handwrittenON CONFLICTSQL.batchsizeandbatchintervalcontrol write batch size and interval. Transient JDBC errors such as connection failures, deadlocks, and rate limiting are retried with exponential backoff.
Recommendation pipeline benchmark
- The example reads watch and like events from Kafka, uses
transformWithStateto track each user's last six watched and last three liked videos, and upserts one Lakebase row peruser_id. - The 60-minute synthetic-data test sustained about 20,000 input events per second across five million active users and recorded 63.5 million upserts. It used 40-core classic compute on DBR 18 LTS, an 8-CU Lakebase project, and five-minute Real-Time Mode checkpoint intervals. Latency from the Kafka input timestamp to the row landing in Lakebase was 183 ms at P50 and 354 ms at P99, specific to this setup.
Source: Databricks Blog (Postgres / Lakebase)· databricks.com
PG Radar summarizes verified changes and impact. Read the original post for full technical details and code samples.