Skip to content

fix: let SQLite name the missing column in null_absent_columns - #399

Merged
abrignoni merged 1 commit into
mainfrom
fix/null-absent-columns-explain
Aug 8, 2026
Merged

fix: let SQLite name the missing column in null_absent_columns#399
abrignoni merged 1 commit into
mainfrom
fix/null-absent-columns-explain

Conversation

@abrignoni

Copy link
Copy Markdown
Owner

Replaces null_absent_columns() with the version proved out in ALEAPP (#1077).

Why the first version needed replacing

It guessed which bare words in a SQL statement were column references, using a rule carried over from Core Data work that only considered names beginning with Z. That is correct for iOS stores and useless for names like _source, ap_temp or lastUpdated.

The consequence was the worst kind: it compiled, passed lint, passed CI, and did nothing at all on the artifacts it had been added for. Only a corpus sweep caught it — the same no such column lines were still there afterwards.

What it does now

It compiles the query with EXPLAIN and replaces whatever SQLite objects to, repeatedly, until the statement compiles. SQLite owns the syntax, so it names the missing column itself and there is nothing left to guess. Qualified and bare references are handled identically, and EXPLAIN compiles without running, so it costs nothing on a large table.

It still emits NULL AS <name> where the reference is a select item in its own right, because artifacts read rows by name and a bare NULL renames the output column.

Scope and verification

No call sites in this repo, so no artifact behaviour changes; this keeps the helper correct for when it is used.

Verified the ported function behaves identically across cores against a real ThreeBars.sqlite missing ZLOWQUALITY: 97 rows, column name preserved, value None — the same result in ALEAPP, DLEAPP, RLEAPP and VLEAPP.

In ALEAPP, where it does have call sites, the corrected version took a 12-corpus sweep from 45 error lines to 8, recovered 23 artifact/corpus pairs (including 4,474 temperature readings and 839 netstat rows the previous version left on the floor), with 2,630 pairs identical and zero regressions.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com

The first version guessed which bare words in a statement were column
references, with a rule carried over from Core Data work that only considered
names beginning with Z. That is useless for other column names, and it failed
silently: it compiled, passed CI, and did nothing on the artifacts it was added
for.

It now compiles the query with EXPLAIN and replaces whatever SQLite objects to,
repeatedly, until it compiles. No guessing, and qualified and bare references
behave the same. Proved out in ALEAPP PR #1077.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@abrignoni
abrignoni merged commit ce8c7c5 into main Aug 8, 2026
4 checks passed
@abrignoni
abrignoni deleted the fix/null-absent-columns-explain branch August 8, 2026 21:45
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