From Synthetic Tickets to Five National Charity Registers on Databricks Free Edition
For three episodes we worked on made-up support tickets. That was on purpose: synthetic data let us focus on Genie Code, Agent Bricks and Unity Catalog semantics without worrying about privacy or licences. At the end of Episode 3 we promised real data. This is it.
From this episode on we build Charity Lens: a public Databricks App where donors can compare charities in the UK (England and Wales), Canada, Australia, the US and Poland, see where the money goes, and later ask a helpdesk agent that cites its sources. Today we do the unglamorous part that decides whether the rest works:
- download five national registers of open data,
- make sure no personal data ever reaches the workspace,
- upload only safe files to a Unity Catalog volume,
- let Genie Code in Agent mode build one pipeline that maps all five countries to a common schema,
- store licence and attribution as UC tags, next to the data.
Everything runs on Databricks Free Edition.
Clip 1: five registers, five meanings of "charity".
Five countries, five definitions
The first surprise is that "charity" is not one thing:
| Jurisdiction | What we load | What "charity" means there |
|---|---|---|
| England & Wales | Charity Commission register extract (23 Oct 2026) | registered charity under the Charities Act 2011; Scotland and Northern Ireland have their own regulators |
| Canada | CRA T3010 returns, 2024 fiscal periods | registered charity under the Income Tax Act (charitable organisations, public and private foundations) |
| Australia | ACNC register + 2024 Annual Information Statements | registered charity under the Charities Act 2013 |
| US | IRS Exempt Organizations Business Master File + Form 990 e-file index and a 500-return sample | 501(c)(3) exempt organisations; the smallest ones file only a 990-N postcard, with no financials |
| Poland | NIW-CRSO list of public-benefit organisations (OPP) eligible for 1.5% of income tax, plus a 200-entity KRS sample | there is no legal "charity" category; OPP is a status granted to NGOs |
So we never pretend the rows are like-for-like. Each row in our gold table carries a note that says what it is.
Step 1: Only PII-free files leave the laptop
Public registers still contain personal data. Small charities often list a trustee's home address or private e-mail. US 990 returns name officers and their pay. Polish KRS extracts list board members. Charity Lens doesn't need any of that, so we remove it before upload:
- UK: we never downloaded the trustee table, and our
.nopiicopy of the charity table drops contact addresses, phone and e-mail (we keep the postcode district). - Australia and Canada:
.nopiicopies drop address lines and full postcodes; Canada also loses recipient names in Schedule 2 and e-mail addresses posing as websites. - US: we don't upload the XML returns at all. A small script parses only organisation-level fields (EIN, name, state, revenue, expenses, employees, website).
- Poland: from KRS we keep organisation fields only, no people and no e-mail.
A staging script copies an explicit allow-list into one folder, refuses to run if a deny-listed file sneaks in, and writes SHA-256 checksums. We upload that folder and nothing else.
cd tutorials/e04-five-registers/upload
python3 stage_upload.py
# staged 26 files, 1,140.4 MB
cd ../../../charity-lens/upload && sha256sum -c SHA256SUMS
Then in Catalog Explorer: workspace > charity_lens > volume raw > Upload to this volume, one country folder at a time. Free Edition compute can reach only a limited set of trusted domains, so uploading files is the simplest path. The Catalog Explorer UI accepts files up to 5 GB each; our largest staged files are about 318 MB and 231 MB, so a per-country UI upload is enough.
Clip 2: staging with checksums, then the upload.
Step 2: Teach Genie Code the registers with a skill
As in Episode 1, we give Genie Code a Markdown skill: charity-lens-registers/SKILL.md in /Users/{username}/.assistant/skills/. It lists every file with its quirks (the UK extract is tab-separated with unescaped quotes, Canadian financial columns are T3010 line numbers like 4700, Polish organisation names span several lines), the common schema, the cause mapping rules, and two hard rules: no columns for people, and no currency conversion without a sourced rate.
First we just ask what we have:
@charity-lens-registers List the files in /Volumes/workspace/charity_lens/raw/ by country with their size. For each country, read the header of the main file and tell me which columns will give us the charity ID, name, causes, income, expenditure and currency. Don't create anything yet.
Genie Code noticed the quirks itself: the UK files are tab-separated, the Canadian and Australian headers contain spaces, and it proposed a column mapping per country without creating anything.
Step 3: One pipeline, five countries, one schema
Then we ask for the pipeline (full prompt in prompts/genie_code_prompts.md): bronze materialized views over each file with read_files, and one silver table per country with exactly the same columns:
charity_id, jurisdiction, name, legal_form, registration_status, causes, region_admin1, locality, programme_countries, fiscal_year_end, income, expenditure, charitable_spending, fundraising_spending, currency, employees, website, source, source_url, licence (plus a few helper columns).
Some mapping decisions worth knowing:
- IDs are prefixed so they never collide:
GB-CHC-,CA-CRA-,AU-ABN-,US-EIN-,PL-KRS-. - Income: UK latest income, Canada line 4700, Australia AIS total revenue, US 990 revenue (or the BMF revenue amount), Poland none, because OPP financial reports are PDFs without bulk reuse terms.
- Currency stays local: GBP, CAD, AUD, USD, PLN. We don't convert in this episode. When we do, we'll use one published reference rate per year and show the source in the table. Adding up pounds and złoty is the fastest way to a wrong chart.
An honest note. Genie Code's own attempt at this pipeline stalled. In our first take it spent about 45 minutes on it and never got to a run: its edits to the pipeline files were rejected as stale, it created the pipeline with the wrong default schema (workspace.default instead of workspace.charity_lens), and it could not change the schema afterwards. So in the take you see, we set the default schema to charity_lens in the pipeline settings ourselves and swapped in the fallback SQL from the repo (fallback/e04_pipeline_all.sql). The clip says so in its caption. The fallback is the same bronze, silver and gold design, written and tested in advance.
With the fallback, a full refresh on serverless took about two minutes. All 25 datasets came up green:
| silver table | organisations |
|---|---|
silver_uk_charities (GB-EAW) |
171,914 |
silver_ca_charities |
83,761 |
silver_au_charities |
65,907 (607 rows without an ABN dropped) |
silver_us_charities |
1,650,468 |
silver_pl_charities |
9,604 |
gold_charities |
1,981,654 (the sum of the five) |
Step 4: Five registers side by side
The hero of this episode is a five-row table, gold_jurisdiction_summary:
| jurisdiction | currency | organisations | share_with_income | share_zero_income | share_with_cause | orgs_in_median | median_income_local |
|---|---|---|---|---|---|---|---|
| AU | AUD | 65,907 | 0.788 | 0.154 | 0.869 | 41,779 | 152,396 |
| CA | CAD | 83,761 | 0.951 | 0.009 | 1.000 | 78,905 | 169,028 |
| GB-EAW | GBP | 171,914 | 0.947 | 0.072 | 0.999 | 150,422 | 26,108 |
| PL | PLN | 9,604 | 0 | 0 | 0.020 | 0 | – |
| US | USD | 1,650,468 | 0.664 | 0.395 | 0.789 | 444,574 | 207,104 |
The median uses only organisations with income above zero, in local currency. Read it with the definitions from the first table: the UK median is low because the register includes thousands of very small charities; the US figure covers only 501(c)(3) organisations that report revenue, and 39.5% of US rows have zero or missing income largely because many of the smallest organisations file only a 990-N postcard. Poland has no row in the median at all: the OPP list has no open financial data, so income is NULL by design. Genie Code made the same point when it explained the columns: these rows are not like-for-like.
Step 5: Causes across countries
Each register classifies purposes differently: the UK has 17 "What" codes, Canada 30 categories, Australia 12 charitable-purpose flags, the US the NTEE major groups, and in Poland we only have activity codes (PKD) for our KRS sample. A small cause_map.csv maps all of them to one Charity Lens vocabulary (education, health, poverty, religion, environment, animals and so on). It's version 0. In Episode 5 we turn it into a proper ontology.
Top five causes as a share of each country's organisations (one organisation can have several causes):
| jurisdiction | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| AU | religion 27.6% | poverty 22.1% | education 20.7% | general 11.2% | health 10.7% |
| CA | religion 37.8% | poverty 13.3% | education 12.7% | grantmaking 10.1% | sport 7.4% |
| GB-EAW | education 48.7% | general 34.4% | religion 21.7% | sport 21.0% | poverty 19.9% |
| PL | education 1.5% | other 1.0% | poverty 0.9% | arts 0.8% | sport 0.7% |
| US | religion 12.5% | education 11.2% | poverty 10.5% | arts 7.2% | grantmaking 6.4% |
Poland's shares are tiny because only about 2% of OPP organisations matched our 200-entity KRS sample with activity codes. The check for UK "What" codes and Canadian categories missing from the cause map returned no rows: every source code is mapped in v0. The UK "How" and "Who" codes are left out on purpose, because only "What" feeds causes.
Step 6: Licence and attribution live in Unity Catalog
Open data comes with conditions: OGL in the UK and Canada, CC BY in Australia, CC0 in Poland, and a credit request from the IRS. We store that next to the data as UC tags on the five silver tables: source, licence, licence_url, attribution, extract_date and contains_pii = 'false', plus a table comment that says what a row means. gold_charities gets licence = 'mixed' and points to the per-row licence column. The volume raw got only two tags in this take, domain and contains_pii; its licence and attribution live in the per-table tags and in the repo README. The App will later read those tags to print attributions automatically.
A final check over information_schema.columns searched for column names that look like an address, e-mail, phone number or person's name. It matched 50 columns, and Genie Code reviewed every hit: none is personal data. They are organisation names, counts such as the number of responsible persons, postcode districts, organisation websites, and beneficiary flags such as Aged_Persons.
What we learned
- Genie Code needed more than a nudge on the pipeline. It stalled on stale file edits and a wrong default schema, so we used the fallback SQL from the repo. Set the pipeline's default schema yourself before you ask for code, and keep a tested fallback.
- With a skill that lists the file quirks, the exploration, the summary, the cause analysis and the licence tags all worked on the first prompt.
- Real open data is mostly about edge cases: separators, multi-line names, line-number column names.
- Privacy is a pipeline step that runs before upload, not a filter in the App.
Licences and attribution
- Contains public sector information licensed under the Open Government Licence v3.0. Source: Charity Commission for England and Wales, Register of Charities (extract 23 Oct 2026).
- Contains information licensed under the Open Government Licence – Canada. Source: Canada Revenue Agency, T3010 2024 List of charities (Open Government Licence – Canada 2.0).
- Source: Australian Charities and Not-for-profits Commission (ACNC), data.gov.au, licensed under CC BY 3.0 AU.
- Source: U.S. Internal Revenue Service, Exempt Organizations Business Master File and Form 990 series e-file data, irs.gov. Not endorsed by the IRS.
- Źródło / Source: Narodowy Instytut Wolności – CRSO, Wykaz OPP 1,5% updated 13 Oct 2026 (dane.gov.pl), CC0 1.0; Ministerstwo Sprawiedliwości, Krajowy Rejestr Sądowy (Open API), public-sector information reused under the Act of 11 August 2021 on open data, processed organisation-level sample obtained 25 Oct 2026.
Charity Lens is an independent project, not endorsed by any of these publishers. Information, not financial or legal advice.
Next
Episode 5: what is a charity? We build one cross-jurisdiction ontology over these five registers, metric views for charity finance, and a Genie space that can compare spending across countries.
All code, prompts and the skill are in the repo folder e04-five-registers/.