{"id":46988097,"url":"https://github.com/guidok91/spark-structured-streaming-kafka","last_synced_at":"2026-03-11T13:43:10.725Z","repository":{"id":130694363,"uuid":"358644003","full_name":"guidok91/spark-structured-streaming-kafka","owner":"guidok91","description":"Spark Structured Streaming data pipeline that processes movie ratings data in real-time.","archived":false,"fork":false,"pushed_at":"2026-01-16T09:45:01.000Z","size":290,"stargazers_count":13,"open_issues_count":0,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-16T23:49:44.606Z","etag":null,"topics":["apache-iceberg","apache-kafka","apache-spark","data-engineering","etl","kafka","pyspark","real-time","spark","spark-structured-streaming","streaming"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guidok91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-04-16T15:32:11.000Z","updated_at":"2026-01-16T09:45:04.000Z","dependencies_parsed_at":"2025-02-06T13:39:16.954Z","dependency_job_id":"f8816ccf-a168-4cc7-b518-b89f2d80fb00","html_url":"https://github.com/guidok91/spark-structured-streaming-kafka","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/guidok91/spark-structured-streaming-kafka","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidok91%2Fspark-structured-streaming-kafka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidok91%2Fspark-structured-streaming-kafka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidok91%2Fspark-structured-streaming-kafka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidok91%2Fspark-structured-streaming-kafka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guidok91","download_url":"https://codeload.github.com/guidok91/spark-structured-streaming-kafka/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guidok91%2Fspark-structured-streaming-kafka/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30382676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T12:49:11.341Z","status":"ssl_error","status_checked_at":"2026-03-11T12:46:41.342Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-iceberg","apache-kafka","apache-spark","data-engineering","etl","kafka","pyspark","real-time","spark","spark-structured-streaming","streaming"],"created_at":"2026-03-11T13:43:09.910Z","updated_at":"2026-03-11T13:43:10.695Z","avatar_url":"https://github.com/guidok91.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spark Structured Streaming Demo\n[Spark Structured Streaming](https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html) data pipeline that processes movie ratings data in real-time.\n\nConsumes events from a Kafka topic in Avro, transforms and writes to an [Apache Iceberg](https://iceberg.apache.org/) table.\n\nThe pipeline handles updates and duplicate events by merging to the destination table based on the `event_id`.\n\nThe output table is partitioned by `days(rating_timestamp)` (leveraging [Iceberg's hidden partitioning](https://iceberg.apache.org/docs/latest/partitioning/) for optimal querying)\n\n- [Data Architecture](#data-architecture)\n- [Local setup](#local-setup)\n- [Dependency management](#dependency-management)\n- [Running instructions](#running-instructions)\n- [Table internal maintenance](#table-internal-maintenance)\n\n## Data Architecture\n\u003cimg width=\"1731\" alt=\"image\" src=\"https://github.com/user-attachments/assets/79551b02-e192-4203-9d6b-2ce07253056f\" /\u003e\n\n## Local setup\nWe spin up a local Kafka cluster with Schema Registry based on the [Docker Compose file provided by Confluent](https://github.com/confluentinc/cp-all-in-one/blob/v8.1.1/cp-all-in-one-community/docker-compose.yml).\n\nWe install a local Spark Structured Streaming app using uv.\n\n## Dependency management\nDependabot is configured to periodically upgrade repo dependencies. See [dependabot.yml](.github/dependabot.yml).\n\n## Running instructions\nRun the following commands in order:\n* `make setup` to install the Spark Structured Streaming app on a local Python env.\n* `make kafka-up` to start local Kafka in Docker.\n* `make kafka-create-topic` to create the Kafka topic we will use.\n* `make kafka-produce-test-events` to start writing messages to the topic.\n\nOn a separate console, run:\n* `make streaming-app-run` to start the Spark Structured Streaming app.\n\nOn a separate console, you can check the output dataset by running:\n```python\n$ make pyspark\n\u003e\u003e\u003e df = spark.read.table(\"movie_ratings\")\n\u003e\u003e\u003e df.show()\n+--------------------+--------------------+--------------------+------+-----------+-------------------+\n|            event_id|             user_id|            movie_id|rating|is_approved|   rating_timestamp|\n+--------------------+--------------------+--------------------+------+-----------+-------------------+\n|ad8f6fa4-f2bf-11f...|ad8f6fb8-f2bf-11f...|ad8f6fc2-f2bf-11f...|   4.1|      false|2026-01-16 09:42:31|\n|ad8fe38a-f2bf-11f...|ad8fe39e-f2bf-11f...|ad8fe3a8-f2bf-11f...|   9.7|       true|2026-01-16 09:42:31|\n|ad900496-f2bf-11f...|ad9004aa-f2bf-11f...|ad9004b4-f2bf-11f...|   3.0|      false|2026-01-16 09:42:31|\n|ad901670-f2bf-11f...|ad90167a-f2bf-11f...|ad901684-f2bf-11f...|   3.0|      false|2026-01-16 09:42:31|\n+--------------------+--------------------+--------------------+------+-----------+-------------------+\n```\n\n## Table internal maintenance\nThe streaming microbatches can produce many small files and constant table snapshots.\n\nIn order to tackle these issues, the recommended Iceberg table maintenance operations can be used, [see doc](https://iceberg.apache.org/docs/latest/spark-structured-streaming/#maintenance-for-streaming-tables).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguidok91%2Fspark-structured-streaming-kafka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguidok91%2Fspark-structured-streaming-kafka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguidok91%2Fspark-structured-streaming-kafka/lists"}