> ## Documentation Index
> Fetch the complete documentation index at: https://calendar-effects.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 2026-11-17 · Mahad · The streaming job reads Kafka end to end (local Kafka)

* **Done:**
  * Ran `src/streaming/job.py --source kafka` against a local Kafka 4.4 broker, fed by Sanchi's `src/producers/replay_master.py`. All 27,654 `clean/master.parquet` messages went to topic `calendar-effects-master` (created with `scripts/create_topics.py`).
  * The job read 110 messages per micro-batch (`--max-per-trigger 110`, 10 trading days), so the 10 years took 2 min 14 s, and it printed each event's CAR as its window closed.
  * No code changed. This is the Kafka path the file replay could not test: the connector download, JSON parsing with `FAILFAST`, and the watermark on Kafka data.
  * **Merged Anushiya's 5 commits** (spike rule, `run_everything.sh`, README, tickers) with the config-driven pipeline (decision 0005):
    * `master` keeps her `country` and `retailer_type` columns. `etl/join_master.py` now copies them from `config/retailers.csv`, and the market index gets `MARKET_COUNTRY`/`MARKET_RETAILER_TYPE` from `common.study`.
    * `lookup/tickers.csv`, `etl/tickers_build.py` and `clean/tickers.parquet` were removed as copies, and `run_everything.sh` no longer calls the build script.
    * After the merge, 84 tests pass and `./run_everything.sh --skip-etl` PASSED.
* **Results:**
  * `scripts/check_streaming.py`: 25,050 daily rows and all 600 event CARs match the direct computation (largest difference 1.1e-16, the same as the file replay).
  * The watermark dropped 0 rows. The 90 rows "only in batch" are the last trading days the watermark holds back, as `docs/data-contracts.md` describes.
* **Decisions:** none.
* **Contracts:** `master` gains `country` and `retailer_type` (string), in `docs/data-contracts.md` and `src/common/contracts.py`. Kafka messages carry them too; the streaming job ignores them.
* **Next:**
  1. The same run on the course cluster: done on 2026-11-18. The command first written here failed (the connector must go on `spark-submit --packages`); use the one in `docs/handoffs/2026-11-18-mahad-cluster-kafka.md`.
  2. Streaming vs batch comparison, once Areej's answer key and its contract are in.
  3. Pick the alerts for the demo video.
* **Blocked on / needs from others:**
  * **Areej:** the batch CAR output and its contract in `docs/data-contracts.md`, keyed by `ticker`, `event_type`, `event_date` (decision 0004). The comparison waits on it.
  * **Sanchi:** the late-data test can now run on a laptop with the recipe below. Add `--late-fraction 0.02` to the replay command, then run the check.
  * **Anushiya:** please review the tickers merge, described under Consequences in decision 0005. Shopify's country is `CA` in `config/retailers.csv` (`Canada` in your old list).
* **Local Kafka recipe (Mac):**
  1. Install and format once:
     ```
     brew install kafka
     kafka-storage format --standalone -t "$(kafka-storage random-uuid)" -c /opt/homebrew/etc/kafka/server.properties
     ```
  2. Start the broker and leave it running:
     ```
     kafka-server-start /opt/homebrew/etc/kafka/server.properties
     ```
  3. In another terminal, run `source .venv/bin/activate` and `export JAVA_HOME=/opt/homebrew/opt/openjdk@21`, then:
     ```
     python3 scripts/create_topics.py --bootstrap localhost:9092
     python3 src/producers/replay_master.py --bootstrap localhost:9092 --seconds-per-day 0
     python3 src/streaming/job.py --source kafka --bootstrap localhost:9092 --max-per-trigger 110 --once --fresh
     python3 scripts/check_streaming.py
     ```
  4. **Activate `.venv` first.** If your shell sets `PYSPARK_PYTHON=python3`, Spark's workers use whichever `python3` comes first on PATH. Without the venv that Python has no pyarrow, and the job fails with `ModuleNotFoundError: No module named 'pyarrow'`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.