pyspark-structured-streaming

Build PySpark Structured Streaming pipelines for Kafka, file, and rate sources.

14|1|Updated May 5, 2026
One-click install
npx skills add https://github.com/ivanshamaev/de-agent-skills --skill pyspark-structured-streaming
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pyspark-structured-streaming
Source: https://github.com/ivanshamaev/de-agent-skills/tree/main/skills/pyspark_streaming
Command: npx skills add https://github.com/ivanshamaev/de-agent-skills --skill pyspark-structured-streaming

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you design and operate PySpark Structured Streaming pipelines for reliable real-time processing, including correct handling of event time, late data, stateful aggregations, and durable restarts.

Core Features & Use Cases

  • End-to-end streaming pipeline setup: configure a streaming job in PySpark for Kafka/file/rate sources and run it as a managed streaming query.
  • Event-time correctness: define watermarks and windowing (tumbling/sliding/session) to handle late events and bound state.
  • Production-grade reliability patterns: apply checkpointing, deduplication, foreachBatch for custom sinks, and production state store tuning with RocksDB; covers Kafka source/sink configuration, stream-stream joins with watermarks, and fault tolerance.
  • Typical use cases: Kafka → Delta/Iceberg for silver-lake upserts, near-real-time dashboards with update/append modes, and debugging/monitoring with streaming query progress metrics.

Quick Start

Ask the assistant to generate a PySpark Structured Streaming job that reads JSON events from Kafka, applies an event-time watermark with a tumbling window, deduplicates by a natural key, and writes results to a Delta Lake table using foreachBatch with a durable checkpoint location.

Frequently Asked Questions about pyspark-structured-streaming

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a PySpark Structured Streaming pipeline that reads from Kafka and writes to Delta Lake?

PySpark Structured Streaming pipelines read Kafka JSON events by defining a streaming read stream, applying transformations, and using foreachBatch to write micro-batch outputs to Delta Lake with a durable checkpoint location for fault tolerance.

How does event-time watermarking handle late data in PySpark stateful aggregations?

Event-time watermarking in PySpark tracks the maximum event time observed and automatically drops late data older than the threshold, bounding state size during stateful aggregations across tumbling, sliding, or session windows.

What is the best way to deduplicate streaming events and perform upserts in PySpark?

The best way to deduplicate streaming events is using PySpark's built-in deduplication keyed by a natural key, combined with foreachBatch to execute custom upsert logic into sinks like Delta Lake or Iceberg while maintaining fault tolerance through checkpointing.

Can I use stream-stream joins with watermarks in PySpark Structured Streaming?

Yes, stream-stream joins in PySpark Structured Streaming require defining event-time watermarks on both input streams to bound state and manage late data, ensuring the engine correctly matches events within the defined time constraints.

Why do I need to enable RocksDB state store for my PySpark streaming job?

You need to enable the RocksDB state store to improve performance and memory management for PySpark streaming jobs with large stateful aggregations, preventing out-of-memory errors and maintaining operational reliability during complex stateful transformations.

Does PySpark Structured Streaming support writing processed data to Apache Iceberg?

Yes, PySpark Structured Streaming supports writing processed data to Apache Iceberg by utilizing the foreachBatch output sink, which allows you to perform custom upserts and multi-sink logic for production-ready fault-tolerant outputs.