Append monthly files under a declared schema · SQL
Task: the rules
Inputs (three files, all text) jan(id, amount) feb(id, amount, channel) bad(id, currency) Rules Schema: required columns id and amount; optional column channel. No other columns are allowed. A file missing a required column, or containing a column outside the schema, is rejected as a whole. Keep every row of accepted files. A missing optional column gives a missing channel. source_file is the name of the file the row came from (jan, feb, …). amount is always a whole number in accepted files. Output (row order does not matter) clean(id text, amount int64, channel text, source_file text)
Tab inserts spaces. Press Escape, then Tab, to move focus out of the editor.
| # | idstring | amountstring |
|---|---|---|
| 1 | iz6d | 8 |
| 2 | rna5 | 262 |
| 3 | s38t | 410 |
| 4 | pk5w | 345 |
| 5 | r8id | 426 |
| 6 | azjp | 425 |
Run preview · in your browser, not a grade
Loading the preview runtime…
Check answer · graded on an isolated server, including hidden datasets
Your code runs in a locked-down machine with no network, on the visible data and on hidden datasets that follow the same rules.
Learn from this exercise
A worked solution becomes available after your first check or once you've used every hint.