Bank of England rate history example + Windows encoding fix for the examples runner - #40
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 Windows781cdb59fixed binary resolution on win32, but the suite still depended onPYTHONIOENCODING=utf-8 PYTHONUTF8=1being set externally. Without them there are three separate cp1252 failures, only the first of which is obvious:✓/✗UnicodeEncodeErrorbefore any results are reportedsubprocess.run(text=True)formatting_showcase,showcase_deterministic)open(sql_file, 'r')get_data_file_hint, the-- #!hint is silently swallowed by the bareexcept, 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–2025258 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 25date format the engine treats as a plain string —ORDER BYsorts lexically andYEAR()returns nonsense.scripts/enrich_boe_rates.pyrewrites 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 BYover derived date parts,CASEbanding via CTE,LAGcross-checked against a precomputed column, and date-range filtering. Registered as a formal test with a captured expectation.Testing
main— verified by stashing this work and running the suite against pristinefd04d80for a baseline. Unchanged by this PR.cargo fmt --checkclean — no Rust changes in this PR.🤖 Generated with Claude Code