mcpField
D
databricks-spark-structured-streaming

databricks-spark-structured-streaming

github.com/databricksData & databases373311 installsUpdated today
Repository

About databricks-spark-structured-streaming

databricks-spark-structured-streaming is a guide for building and operating production Spark Structured Streaming pipelines. It collects patterns for Kafka, stream joins, multi-sink writes, state management, and real-time mode.

Key features

  1. 01Kafka streaming patterns
  2. 02Real-Time Mode setup and monitoring
  3. 03Stream-stream and stream-static joins
  4. 04Multi-sink writes and MERGE tuning
  5. 05Checkpoint and stateful-operation configuration
  6. 06Production checklist

Use cases

  1. 01Stream Kafka data into Delta
  2. 02Process events with low latency
  3. 03Join streaming data with static data
  4. 04Write streaming records to multiple tables

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/databricks/databricks-agent-skills --skill databricks-spark-structured-streaming

After installing, type/databricks-spark-structured-streamingin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

agents/
openai.yaml
assets/
databricks.svg
references/
checkpoint-best-practices.md
kafka-streaming.md
lakebase-sink-python.md
merge-operations.md
multi-sink-writes.md
real-time-mode.md
stateful-operations.md
stream-static-joins.md
stream-stream-joins.md
streaming-best-practices.md
trigger-and-cost-optimization.md

Details

From the project README

Spark Structured Streaming

Production-ready streaming pipelines with Spark Structured Streaming. This skill provides navigation to detailed patterns and best practices.

Quick Start

from pyspark.sql.functions import col, from_json

# Basic Kafka to Delta streaming
df = (spark
    .readStream
    .format("kafka")
    .option("kafka.bootstrap.servers", "broker:9092")
    .option("subscribe", "topic")
    .load()
    .select(from_json(col("value").cast("string"), schema).alias("data"))
    .select("data.*")
)

df.writeStream \
    .format("delta") \
    .outputMode("append") \
    .option("checkpointLocation", "/Volumes/catalog/checkpoints/stream") \
    .trigger(processingTime="30 seconds") \
    .start("/delta/target_table")

Core Patterns

PatternDescriptionReference
Kafka StreamingKafka to Delta, Kafka to Kafka, Real-Time ModeSee references/kafka-streaming.md
Real-Time Mode (RTM)Sub-second E2E latency — cluster setup, slot math, supported ops (incl. stream-stream inner join on DBR 18+), transformWithState, observability, error classes, delivery semanticsSee references/real-time-mode.md
Lakebase SinkWrite streaming records into Lakebase Postgres with transactional upserts. Native format("postgresql") sink (DBR 18.3+) and manual foreach sink as a fallbackSee references/lakebase-sink-python.md
Stream JoinsStream-stream joins, stream-static joinsSee references/stream-stream-joins.md, references/stream-static-joins.md
Multi-Sink WritesWrite to multiple tables, parallel mergesSee references/multi-sink-writes.md
Merge OperationsMERGE performance, parallel merges, optimizationsSee references/merge-operations.md

Configuration

TopicDescriptionReference
CheckpointsCheckpoint management and best practicesSee references/checkpoint-best-practices.md
Stateful OperationsWatermarks, state stores, RocksDB configurationSee references/stateful-operations.md
Trigger & CostTrigger selection, cost optimization, RTMSee references/trigger-and-cost-optimization.md

Best Practices

TopicDescriptionReference
Production ChecklistComprehensive best practicesSee references/streaming-best-practices.md

Production Checklist

  • Checkpoint location is persistent (UC volumes, not DBFS)
  • Unique checkpoint per stream
  • Fixed-size cluster (no autoscaling for streaming)
  • Monitoring configured (input rate, lag, batch duration)
  • Exactly-once verified (txnVersion/txnAppId)
  • Watermark configured for stateful operations
  • Left joins for stream-static (not inner)

Comments

Markdown supported