Image: databricks.comDatabricks has closed one of the messier gaps between streaming analytics and operational serving. On November 23, 2026, the company made its native Lakebase Postgres sink for Apache Spark Structured Streaming generally available, so a single writeStream call can upsert computed results into Lakebase with built-in batching, connection pooling, retries, and workspace-managed authentication.
Low-latency jobs such as fraud detection, live personalization, and real-time feature stores have long needed two systems. Spark can compute the features. Lakebase, Databricks' fully managed serverless PostgreSQL, can serve them, with autoscaling, branching, Unity Catalog integration, and sub-10 millisecond reads. The missing piece was a production-grade write path. Until this release, that path was a custom foreach writer that a team had to batch, retry, pool, and keep correct under load.
What became generally available
The engineering post, written by Navneeth Nair, David Young, and Murali Talluri, describes a Structured Streaming connector that writes computed results straight into Lakebase. It is generally available on Databricks Runtime 18 LTS and above. The same connector works in micro-batch mode and in Real-Time Mode.
Image: databricks.comTrigger support is not uniform across compute types. RealTime and ProcessingTime run on classic compute. On serverless notebooks and jobs, those triggers are not available, and teams use Trigger.AvailableNow, which processes data that has arrived since the last checkpoint and then exits. Official documentation also states that Lakeflow pipelines are not supported. The blog FAQ describes the same boundary as a lack of support in Apache Spark Declarative Pipelines.
The timing fits a busy stretch for the database itself. Postgres 19 became selectable for new Lakebase projects on November 19, 2026, the same day the PostgreSQL community shipped that major version. Lakebase Postgres reached general availability on Google Cloud on November 2, after earlier production availability on AWS and a staged Azure rollout. The streaming sink is the piece that turns that database into a first-class destination for Spark jobs that cannot wait on a scheduled sync.
Why custom foreach writers were the bottleneck
A production foreach writer is not a short snippet. Databricks says it has to batch writes for throughput, keep a bounded queue for backpressure, pool connections, refresh OAuth tokens, retry transient failures with backoff, deduplicate inside a batch, and implement upsert semantics correctly. That last item includes rules such as keeping the greatest timestamp, or updating a column only when an incoming event carries a newer ordering value.
Image: databricks.comEven experienced developers spend weeks getting that right, and the work does not end at the first successful job. Throughput regressions, credential refresh, and runtime upgrades turn the connector into something the data team has to maintain. Databricks points to a public reference implementation as a picture of that complexity.
DraftKings is already describing the operational difference. Maria Marinova, senior lead software engineer, said the company streams real-time data into Lakebase so a risk agent can pull a user's recent activity when it investigates an alert. The team first built that path with a custom ForeachWriter. Evaluating the native sink, she said, reduced the custom work required for connection pooling, batching, and retries. Georgi Stoychev, senior software automation engineer at DraftKings, made the same point about testing how the risk agent reaches the freshest available user data.
How a streaming upsert lands in Postgres
For a Lakebase table registered in Unity Catalog, the write uses the familiar writeStream API and ends in toTable with a fully qualified catalog.schema.table name. The connector authenticates as the running user or service principal and creates the table if it does not exist.
If the table is not registered in Unity Catalog, the job uses format("postgresql") with an endpoint and a dbtable option. That same format path can also write to external PostgreSQL, including Amazon RDS or a self-hosted database, through a Unity Catalog connection. External writes require Databricks Runtime 19 or later, the target table must already exist, and the capability remains in Public Preview behind the Custom JDBC on UC Compute preview.
Upserts are the behavior when the target has a primary key. Declare an upsertkey, or let the sink read the primary key from an existing table, and writes use PostgreSQL's INSERT ... ON CONFLICT DO UPDATE. Without a primary key, the sink inserts. Output mode does not change that rule: update is supported, append behaves the same way, and complete is not supported.
On Databricks Runtime 19 and above, merge strategies control how non-key columns update on conflict, such as keeping the latest non-null value or the value from the newest event, without hand-written ON CONFLICT SQL. The default strategy is latest. Additive schema evolution through mergeSchema is also a Runtime 19 feature. The sink checks for new columns when the query starts, not at every batch boundary, and it only adds nullable top-level columns. It does not rename, drop, or retype existing columns.
Batching is built in. A flush happens when the buffer reaches batchsize rows, which defaults to 1,000, or when the buffer is older than batchinterval, which defaults to 100 milliseconds. If the database cannot keep up, the sink pushes backpressure to the source. Transient JDBC errors, including connection failures, deadlocks, and rate limiting, are retried with exponential backoff. If retries are exhausted, the query fails rather than silently dropping the batch.
The numbers Databricks published
The engineering post walks through a recommendation feature pipeline. A video platform streams watch and like events from Kafka. Spark groups by user and, using transformWithState, keeps each viewer's last six watched videos and last three liked videos as one row. The native sink upserts that row into Lakebase so a recommendation model can look the user up at inference time. There is no separate offline-to-online sync between the stream and the serving table.
Databricks ran that pattern for an hour at about 20,000 events per second against 5 million active users. The cluster was 40-core classic compute on Runtime 18 LTS, writing to an 8-CU Lakebase project with five-minute Real-Time Mode checkpoints. Every event overwrote that user's existing feature row. That is the pattern that tends to break homemade writers once the table holds millions of keys and every event is an update, not an append.
End-to-end latency, measured from the Kafka input timestamp to the row landing in Lakebase, was 183 milliseconds at the median and 354 milliseconds at the 99th percentile. Databricks says features in the demo landed within 100 to 200 milliseconds of being produced, after which applications can read them in single-digit milliseconds. On the database side, pg_stat_statements showed 63.5 million upserts averaging about 0.015 milliseconds per statement, with headroom left on the 8-CU project. The company has separately argued that Lakebase's separated compute and storage can deliver substantially higher Postgres write throughput than a monolithic layout, which is part of why an 8-CU project absorbed that upsert rate.
Those figures used synthetic data replayed into Kafka on that specific setup. Databricks is explicit that results will differ with input rate, state size, cluster size, and Lakebase size. The post also does not publish a side-by-side comparison against a tuned custom foreach writer, so teams should treat the numbers as a capability demonstration, not a universal service-level agreement.
Practical checks before you retire the glue code
A few choices decide whether the generally available sink fits a given pipeline. The happy path is short. The limits are in the runtime, trigger, and pipeline matrix.
- Start on Runtime 18 LTS or newer. Move to Runtime 19 if you need merge strategies, interval types, additive schema evolution, or external Postgres.
- Register the Lakebase table in Unity Catalog and use toTable when you can. Managed authentication removes token-refresh code from the job.
- Set upsertkey to the full primary key. For an existing table, those columns must match the key exactly, and every key column must be present in the DataFrame.
- Keep identifiers simple if the sink will create the table: start with a letter or underscore, and use only letters, numbers, and underscores. Create the table yourself if you need other names.
- Lower batchinterval for Real-Time Mode latency, and raise batchsize when throughput matters more than the last few milliseconds. Leave the default of one task per database connection unless a connection limit forces a change via spark.databricks.sql.streaming.jdbc.tasksPerConnection.
- Put the checkpoint on a Unity Catalog volume or cloud storage, never local disk, and give each query its own location. Primary-key upserts are the practical idempotency story when a retry or restart replays work.
- Do not plan this sink inside Lakeflow pipelines. Continuous RealTime and ProcessingTime triggers are classic-compute only. Serverless jobs should use AvailableNow.
- Size both sides. A fast sink still stalls if Lakebase compute is too small, or if Spark state for millions of keys does not fit the cluster.
The broader pattern is the one Databricks has been assembling through 2026. Synced tables and bulk loads can move lakehouse data into Postgres for applications. Change data feed can move operational changes back toward Delta. The streaming sink is the low-latency forward path: compute in Spark, serve from Postgres, without a separate online feature store and a hand-maintained JDBC writer.
General availability does not erase every custom writer. External databases are still in preview. Declarative and Lakeflow pipelines are out of scope. Serverless cannot run Real-Time Mode triggers. Teams with unusual conflict rules, exotic identifiers, or tight connection limits will still read the fine print.
For the common case, the operational tax just dropped. A streaming job can compute features as events arrive and upsert one current row per key into a serving database that applications and agents already know how to query. DraftKings' risk-agent path is the clearest early example: recent activity has to be there when an alert is investigated, not after the next batch sync. Databricks published a companion repository for the recommendation pipeline and documentation covering sink options, triggers, and tuning. Teams evaluating the cutover should run that pattern, or a slice of their own keys, against a Lakebase project sized like production before they delete the foreach code. The connector is generally available. The workload still has to be measured.