Skip to content

feat(loader)!: declared columns missing from the data follow on_schema_change - #364

Merged
kvlonge merged 1 commit into
mainfrom
feat/missing-declared-columns
Nov 26, 2026
Merged

kvlonge merged 1 commit into
mainfrom
feat/missing-declared-columns

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

A column declared in columns that the data lacks now follows on_schema_change. Before, it failed plan outright (Parquet files) or loaded as NULL silently (Python tables).

on_schema_change New column in the data Declared column missing from the data
append_new_columns (default) added, inferred loaded as NULL at its declared type, with a warning
ignore not added loaded as NULL at its declared type, with a warning
fail fail fail

A declared column is never dropped.

Changes

  • Files sources. A pin that no sampled file holds becomes a missing column at plan. "Sampled" means the Parquet footers, or the JSON and CSV records. Under fail the plan blocks the table. Otherwise the plan warns and the load fills NULL. This replaces the pinned column ... was not seen in the sampled files note that JSON and CSV tables showed. A pin close to a sampled name (a typo, or a different case) still fails, as before.
  • Python tables. After the function has yielded every row, a warning names each declared column that no row had (columns or parse keys). Under fail the table fails instead. A function that yields no rows reports nothing.
  • Reporting. The library carries the list in TableSpec::missing_columns, TableLoaded::missing_columns and ProjectPlan::missing_columns. plan --json lists it under missing_columns, one {table, columns} per table, and load --json gives missing_columns on each table result. Both are left out when empty, so existing JSON output does not change.
  • Docs. The contracts page has a new section, "Declared columns the data lacks", which includes what fail leaves behind for Python tables.

Breaking change

Under on_schema_change = "fail", a JSON or CSV files table that pins a key no sampled file holds now fails plan. That covers a key only older files have. Before, plan only showed a note. The commit is feat! with a BREAKING CHANGE: footer. Parquet tables with such a pin used to fail plan under every setting. They now load the column as NULL unless the setting is fail.

Python tables under fail

The check runs once every row is in, at the end of the load:

  • replace: the new rows are staged and swapped in only after the whole load succeeds, so a fail leaves the old table and its rows untouched.
  • A table the failed load created: dropped again if nothing has committed to it. This covers a first-load replace, and an append that would have committed once, so no empty table is left visible.
  • An append that committed on the way (about every 1 GB, or per batch_size window): it keeps the rows those commits loaded. The contracts docs say so.

Tests

  • given_a_declared_column_missing_from_the_files_when_loading_then_on_schema_change_decides (loader tests): NDJSON and Parquet under all three values. Parquet is covered both when DuckDB reads the files itself and when SQLLoad's reader does (test_loader_route). The column loads as DATE, all NULL.
  • given_declared_columns_the_data_lacks_when_on_schema_change_decides_then_each_warns_or_the_table_fails (unit test).
  • Python: a declared column no row has, under append_new_columns, ignore and fail (the failed first load leaves no table). A replace under fail: an existing table keeps its old rows, and a first load leaves no table. A declared column that is NULL in every row keeps its declared type with no warning. A files table's plan --json and load --json both list the column.
  • The existing text-files and edge-case loader tests are updated for the new warning text.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Deploying sqlload with  Cloudflare Pages  Cloudflare Pages

Latest commit: cc2f4b2
Status: ✅  Deploy successful!
Preview URL: https://c743dbd6.sqlload.pages.dev
Branch Preview URL: https://feat-missing-declared-column.sqlload.pages.dev

View logs

…a_change

A column declared in `columns` that the data lacks no longer fails plan
unconditionally (Parquet files) or loads as NULL silently (Python
tables). on_schema_change decides: append_new_columns and ignore load it
as NULL at its declared type with a warning, and fail refuses the table.
A declared column is never dropped.

- Files sources: a pin no sampled file holds (Parquet footers as well as
  JSON and CSV records) becomes a missing column at plan. Under fail the
  plan blocks the table; otherwise plan warns and the load fills NULL.
  This replaces the "pinned column ... was not seen in the sampled files"
  note. A pin close to a sampled name (a typo, or another case) still
  fails.
- Python tables: once the function has yielded every row, declared
  columns no row had are warned of, or fail the table under fail. A
  replace keeps the old table, as its rows swap in only at the end, and
  a table the failed load created is dropped again unless rows were
  committed to it. An append that committed on the way keeps those rows.
- Reporting: TableSpec::missing_columns, TableLoaded::missing_columns and
  ProjectPlan::missing_columns carry the list in the library; plan --json
  lists it under missing_columns per table, and load --json on each table
  result. Both are left out when empty.

BREAKING CHANGE: under on_schema_change = "fail", a JSON or CSV files
table that pins a key no sampled file holds (one only older files have)
now fails plan; before, plan only noted it. Parquet tables with such a
pin, which failed plan under every setting, now load it as NULL unless
on_schema_change = "fail".
@kvlonge
kvlonge force-pushed the feat/missing-declared-columns branch from b1380dc to cc2f4b2 Compare November 26, 2026 01:58
@kvlonge kvlonge changed the title feat(loader): declared columns missing from the data follow on_schema_change feat(loader)!: declared columns missing from the data follow on_schema_change Nov 26, 2026
@kvlonge
kvlonge merged commit 7509c0d into main Nov 26, 2026
12 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