Summary
ALTER COLLECTION x ADD COLUMN y ... is documented but rejected at parse time. The underlying handler exists — the router just doesn't dispatch to it for ALTER COLLECTION.
Zero-downtime schema evolution impossible on strict collections. Only workaround is DROP + CREATE + re-ingest (data loss unless caller has their own backup tooling).
Repro
CREATE COLLECTION memories TYPE DOCUMENT STRICT (
id STRING PRIMARY KEY,
name STRING NOT NULL
);
ALTER COLLECTION memories ADD COLUMN is_latest BOOL DEFAULT true;
Error:
parse error: sql parser error: Expected: one of VIEW or TYPE or TABLE or INDEX
Same error for every column type / default combination. ALTER TABLE memories ADD COLUMN is_latest BOOL DEFAULT true works on the same collection.
Expected
Per docs/documents.md:131:
ALTER COLLECTION orders ADD COLUMN region STRING DEFAULT 'us-east';
Root cause — dispatcher asymmetry
In src/control/server/pgwire/ddl/router/schema.rs:
- Line 84 wires
ALTER TABLE ... ADD COLUMN → alter_table_add_column()
- Lines 103–136 wire
ALTER COLLECTION ... for OWNER, SET RETENTION, LAST_VALUE_CACHE, LEGAL_HOLD, SET APPEND_ONLY
- No branch for
ALTER COLLECTION ... ADD COLUMN
Statement falls through to DataFusion's sqlparser-rs, which only knows ALTER {TABLE,VIEW,TYPE,INDEX} — hence the misleading error list.
Handler at src/control/server/pgwire/ddl/collection/alter.rs:14-104 is already catalog-generic, so it would work for collections if the router reached it.
Special case ALTER COLLECTION ... ADD COLUMN ... AS MATERIALIZED_SUM is wired separately at router/collaborative.rs:58-63 — plain ADD COLUMN fell through the cracks.
Tests
tests/sql_transactions.rs:71-76 covers ALTER TABLE ... ADD COLUMN only. No test exercises the documented ALTER COLLECTION ... ADD COLUMN path.
Pointers
- `src/control/server/pgwire/ddl/router/schema.rs:84`
- `src/control/server/pgwire/ddl/router/schema.rs:103-136`
- `src/control/server/pgwire/ddl/router/collaborative.rs:58-63`
- `src/control/server/pgwire/ddl/collection/alter.rs:14-104`
- `docs/documents.md:131`
- `tests/sql_transactions.rs:71-76`
Summary
ALTER COLLECTION x ADD COLUMN y ...is documented but rejected at parse time. The underlying handler exists — the router just doesn't dispatch to it forALTER COLLECTION.Zero-downtime schema evolution impossible on strict collections. Only workaround is
DROP + CREATE + re-ingest(data loss unless caller has their own backup tooling).Repro
Error:
Same error for every column type / default combination.
ALTER TABLE memories ADD COLUMN is_latest BOOL DEFAULT trueworks on the same collection.Expected
Per
docs/documents.md:131:ALTER COLLECTION orders ADD COLUMN region STRING DEFAULT 'us-east';Root cause — dispatcher asymmetry
In
src/control/server/pgwire/ddl/router/schema.rs:ALTER TABLE ... ADD COLUMN→alter_table_add_column()ALTER COLLECTION ...forOWNER,SET RETENTION,LAST_VALUE_CACHE,LEGAL_HOLD,SET APPEND_ONLYALTER COLLECTION ... ADD COLUMNStatement falls through to DataFusion's sqlparser-rs, which only knows
ALTER {TABLE,VIEW,TYPE,INDEX}— hence the misleading error list.Handler at
src/control/server/pgwire/ddl/collection/alter.rs:14-104is already catalog-generic, so it would work for collections if the router reached it.Special case
ALTER COLLECTION ... ADD COLUMN ... AS MATERIALIZED_SUMis wired separately atrouter/collaborative.rs:58-63— plainADD COLUMNfell through the cracks.Tests
tests/sql_transactions.rs:71-76coversALTER TABLE ... ADD COLUMNonly. No test exercises the documentedALTER COLLECTION ... ADD COLUMNpath.Pointers