Skip to content

Bank of England rate history example + Windows encoding fix for the examples runner - #40

Merged
TimelordUK merged 2 commits into
mainfrom
feat/boe-rate-history-example
Jul 30, 2026
Merged

Bank of England rate history example + Windows encoding fix for the examples runner#40
TimelordUK merged 2 commits into
mainfrom
feat/boe-rate-history-example

Conversation

@TimelordUK

Copy link
Copy Markdown
Owner

Recovers and lands work that was in progress when a session crashed. Two independent changes.

1. fix(tests): make the examples runner encoding-safe on Windows

781cdb59 fixed binary resolution on win32, but the suite still depended on PYTHONIOENCODING=utf-8 PYTHONUTF8=1 being set externally. Without them there are three separate cp1252 failures, only the first of which is obvious:

Site Symptom
printing / UnicodeEncodeError before any results are reported
subprocess.run(text=True) engine stdout decoded as cp1252 — mangles non-ASCII, breaks formal JSON comparison (formatting_showcase, showcase_deterministic)
open(sql_file, 'r') UTF-8 example with bytes undefined in cp1252 raises inside get_data_file_hint, the -- #! hint is silently swallowed by the bare except, and the example runs with no data file (solar_system_calculations_simple)

All three are pinned to UTF-8. No behaviour change on Linux/macOS, where UTF-8 was already the locale encoding.

Worth noting the third one fails silently — the hint is dropped and the example proceeds, so it surfaces as a confusing "data file not found" from the engine rather than an encoding error.

2. feat(examples): Bank of England rate history, 1975–2025

258 rate changes from the 1975 post-oil-shock easing through December 2025, tagged with economic eras, the events behind the big moves, and the PM/chancellor/governor of the day.

The raw bankofengland.co.uk download uses a 18 Dec 25 date format the engine treats as a plain string — ORDER BY sorts lexically and YEAR() returns nonsense. scripts/enrich_boe_rates.py rewrites the dates as ISO so a real DATETIME column is inferred, and denormalises the economic context alongside (one data source per invocation, so a join isn't an option).

Both CSVs are committed: the raw download for provenance, the enriched file for the example. Re-running the script reproduces the enriched CSV byte for byte.

The example exercises GROUP BY over derived date parts, CASE banding via CTE, LAG cross-checked against a precomputed column, and date-range filtering. Registered as a formal test with a captured expectation.

Testing

  • Examples suite: 32 formal tests pass (up from 31). The 19 smoke failures are pre-existing on main — verified by stashing this work and running the suite against pristine fd04d80 for a baseline. Unchanged by this PR.
  • Expectation was originally captured against v1.77.3; re-validated against v1.82.0 after rebuild and it holds unchanged.
  • cargo fmt --check clean — no Rust changes in this PR.

🤖 Generated with Claude Code

TimelordUK and others added 2 commits July 30, 2026 23:01
781cdb5 fixed binary resolution on win32 but left the suite dependent on
PYTHONIOENCODING=utf-8 PYTHONUTF8=1 being set externally. Without those the
runner has three separate cp1252 failures:

- printing the check/cross marks dies with UnicodeEncodeError before any
  results are reported;
- subprocess.run(text=True) decodes the engine's stdout with the locale
  encoding, mangling every non-ASCII character and breaking formal JSON
  comparison (formatting_showcase, showcase_deterministic);
- open() reads the .sql files as cp1252, so a UTF-8 example whose bytes are
  undefined in cp1252 raises inside get_data_file_hint, the -- #! hint is
  silently dropped, and the example runs without its data file
  (solar_system_calculations_simple).

Pin all three to UTF-8 so the suite passes on a bare cp1252 console with no
environment setup. No change on Linux/macOS, where UTF-8 was already the
locale encoding.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds a fifty-year worked example over the BoE Bank Rate: 258 rate changes
from the 1975 post-oil-shock easing to December 2025, tagged with economic
eras, the events behind the big moves, and the PM/chancellor/governor of
the day.

The raw bankofengland.co.uk download uses a "18 Dec 25" date format that the
engine treats as a plain string, so ORDER BY sorts lexically and YEAR()
returns nonsense. scripts/enrich_boe_rates.py rewrites the dates as ISO so a
real DATETIME column is inferred, and denormalises the economic context
alongside (one data source per invocation, so a join is not an option). Both
CSVs are committed: the raw download for provenance, the enriched file for
the example. Re-running the script reproduces the enriched CSV byte for byte.

The example exercises GROUP BY over derived date parts, CASE banding via CTE,
LAG cross-checked against a precomputed column, and date-range filtering.
Registered as a formal test with a captured expectation, taking the suite
from 31 formal tests to 32.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@TimelordUK
TimelordUK merged commit 7103edb into main Jul 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant