
A US regional bank moves daily VSAM extracts off its mainframe into Snowflake, and much of that ingestion is custom code. The files are EBCDIC, full of packed decimals, with 63 record types and OCCURS groups of up to 300 entries, and the sensitive columns must be tokenized before they reach Snowflake. For a proof of concept we built four Maia components that read the file through its COBOL copybook. At a third above the bank's current volume, 400 million child rows loaded in 28 minutes 27 seconds on one 8 vCPU runner, tokenization included.
Why copybook files are hard to load
- Encoding. Text is EBCDIC (code page cp037) and numbers are COMP-3 packed decimals or binary, which must become exact decimals, not floats.
- Many record types in one file. Each type is identified by a flag in the record and belongs in its own table.
- OCCURS groups. One account carries up to 300 service-charge slots, most of them empty.
- REDEFINES. The same bytes can be read two ways, and you choose which to load (the defined fields by default).
- Sensitive fields. Account numbers, names, and addresses have to be protected before load, reversibly.
What we built
| Component | What it does |
|---|---|
| Copybook Load | Reads the EBCDIC file from S3 using the copybook, decodes COMP-3 and binary fields to exact decimals, and writes one typed Avro dataset per record type in a single pass |
| Copybook Tokenise | Replaces sensitive values with format-preserving FF1 tokens (AES-256), reversible with the key, or masks them. Fails the run rather than let a protected value through in clear |
| Create Tables from Avro | Creates or extends one Snowflake table per record type, typed from the Avro schema (decimals become NUMBER(p,s)) |
| Copybook Commit | Moves the incremental watermark forward only after every table has loaded, so no record is ever skipped |
Standard Maia components (If, Grid Iterator, AVRO Load) join them up. In production the components run on the runner inside the customer's environment, so no record data passes through the Maia control plane or an LLM; our tests ran on a laptop and in our own AWS account. Maia built the pipeline itself from one detailed prompt, in a conversation of under 2 hours.
OCCURS groups load as flat child tables, one row per entry with its position and the account's business key, or as a Snowflake ARRAY. Empty slots are skipped. A full load and three incremental runs took the tables from 9 accounts to 14, 5,017, and 305,017, adding exactly the new records each time (5, 5,003, and 300,000), with no duplicates and one token per account across every table. If the copybook changes, its fingerprint forces a full reload instead of appending rows of a different shape.
The results
| Test | Volume | Time |
|---|---|---|
| Full load, laptop runner | 305,018 records (3.9 GB) to 6.9 million rows in 29 tables | 4 min 55 s |
| Full scale, one 8 vCPU runner in AWS | 4 million accounts, 400 million child rows (51 GB) | 28 min 27 s |
| Five files at once, one runner on three 8 vCPU instances, Large multi-cluster warehouse | 1.85 billion rows (192 GB) | 24 min 47 s |
By the bank's own figures, its current tools take about 3 hours and, at best, about 30 minutes for up to 300 million child rows. Those are the bank's numbers for its environment, not a side-by-side test.
How 2 hours 32 minutes became 28 minutes
The first full-scale run, on a laptop runner, took 2 hours 32 minutes. Capped at one core, as a default runner is, it took 2 hours 42 minutes even with the first two fixes below. We profiled the slowest stage, changed one thing, checked the output was byte-identical, and measured again:
- Encrypt repeated keys once. Each account's key appears on all 100 of its child rows. Caching the last token halved tokenizing on one core.
- Skip empty OCCURS slots from their raw bytes, without decoding them.
- Use every core, while still writing rows in file order.
- Do less per row. A third of Copybook Load was Avro bookkeeping. CPU per record fell from 0.33 to 0.19 ms.
- Compress staging files lightly. They're about 45% larger and read once, and the load was no slower.
- Overlap network calls, which took Create Tables from Avro from 33 seconds to 2.
- Run next to the data. On the laptop, 37 of 52 minutes were spent waiting on a home network.
Where else this applies
Any team still moving mainframe extracts with hand-written parsers faces the same problems: EBCDIC, packed decimals, OCCURS, and REDEFINES. One lesson travels to any Snowflake workload. Five concurrent files sent up to 150 COPY statements at once, and a single Large cluster queued them (32 minutes in all). A multi-cluster warehouse of one to three clusters finished in 24 minutes 47 seconds. When concurrency is the limit, scale out, not up. Multi-cluster warehouses need Snowflake Enterprise Edition or above.
What to watch for
These components are a working proof of concept, not a released Maia feature, and the test data is synthetic, built from 10 sample records.
- Retries can duplicate. A run that fails part-way through loading re-reads the same records on retry, so tables that had already loaded can get them twice. Nothing is skipped.
- Tokenization limits. FF1 with a demo key stands in for the bank's own service. An early demo run reported success while leaving every ZIP code in clear, because values too short for FF1 passed straight through; now any value the component can't protect fails the run. It doesn't reach fields inside OCCURS groups, and it handles US code pages (cp037).
- Staging is untokenized. Copybook Load writes Avro to S3 before Copybook Tokenise runs, so protect that location like the source.
- Layouts. Files whose layout changes part-way, and nested OCCURS groups of different sizes, aren't handled.
Frequently Asked Questions
We've built and demonstrated components that do it in a proof of concept. They aren't a released Maia feature.
Decoded to exact decimals and loaded as Snowflake NUMBER(p,s).
As flat child tables, one row per entry, or as an ARRAY column. Empty slots are skipped.
In the proof of concept, yes: values are replaced with reversible FF1 tokens on the runner before load. Fields inside OCCURS groups aren't tokenized.
Our latest resources
Data management



