You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
INSERT..SELECT with a kv-engine source silently NULLs expression cells #311
INSERT INTO dst (id) SELECT <expr> FROM src silently writes NULL for the
expression column when the source is a kv-engine collection. The
copy_rows column-map drops expression projections for kv sources, so the
cell is never evaluated — no error, no value.
The same gap remains on the INSERT..SELECT source path for kv: an
accessor there (SELECT nextval('s') FROM kvsrc) inserts NULL silently
instead of raising 0A000 like document/columnar sources do. Pinned as a
known gap in the sequence_matrix wire suite (in-test note).
Expected
Expression cells over kv sources evaluate per row with the same semantics
as other engines (or fail loudly, never silently NULL).
CREATE COLLECTION kvsrc (id BIGINTPRIMARY KEY, v TEXT) WITH (engine ='kv');
INSERT INTO kvsrc (id, v) VALUES (1, 'hello');
CREATE COLLECTION dst (id BIGINTPRIMARY KEY, v TEXT) WITH (engine ='document_schemaless');
INSERT INTO dst (id) SELECTupper(v) FROM kvsrc;
SELECT*FROM dst; -- v is NULL instead of 'HELLO'-- accessor form: INSERT INTO dst (id) SELECT nextval('s') FROM kvsrc; -- NULL, no 0A000
Reproduced on main dd2ed01 and on the PR #307 branch (the gap is in the
copy_rows column-map for kv sources, independent of the kv scan fix).
Accessor form: fixed.INSERT INTO t2 (id) SELECT nextval('s') FROM t over a kv source returns 0A000. Pinned by nextval_as_an_insert_select_source_is_refused in nodedb/tests/wire/cases/sql_sequence_row_scope_refusals.rs (source t is engine = 'kv').
The reproduction above is not a defect.INSERT INTO dst (id) SELECT upper(v) FROM kvsrc writes only the id column, so v is NULL by definition. It also puts a TEXT expression into a BIGINT key.
Still unconfirmed: whether an expression cell reaches a written column over a kv source. The case to run:
CREATE COLLECTION kvsrc (id BIGINTPRIMARY KEY, v TEXT) WITH (engine ='kv');
INSERT INTO kvsrc (id, v) VALUES (1, 'hello');
CREATE COLLECTION dst (id BIGINTPRIMARY KEY, v TEXT) WITH (engine ='document_schemaless');
INSERT INTO dst (id, v) SELECT id, upper(v) FROM kvsrc;
SELECT v FROM dst WHERE id =1; -- expected 'HELLO'
If that returns 'HELLO', this issue can close with that case added as a wire test.
Summary
INSERT INTO dst (id) SELECT <expr> FROM srcsilently writes NULL for theexpression column when the source is a kv-engine collection. The
copy_rows column-map drops expression projections for kv sources, so the
cell is never evaluated — no error, no value.
Evidence
SELECT 1 + 1 FROM kvreturned an empty column until kv scan projectionswere fixed in feat(sql): evaluate sequence accessors in constant contexts and kv projections #307 (KvOp::Scan now carries projection + computed columns).
accessor there (
SELECT nextval('s') FROM kvsrc) inserts NULL silentlyinstead of raising 0A000 like document/columnar sources do. Pinned as a
known gap in the sequence_matrix wire suite (in-test note).
Expected
Expression cells over kv sources evaluate per row with the same semantics
as other engines (or fail loudly, never silently NULL).
Related: #303, #307, #294
Reproduction
Reproduced on main dd2ed01 and on the PR #307 branch (the gap is in the
copy_rows column-map for kv sources, independent of the kv scan fix).
Status on
main@ 1ff3551 (re-verified 2026-09-28)INSERT INTO t2 (id) SELECT nextval('s') FROM tover a kv source returns0A000. Pinned bynextval_as_an_insert_select_source_is_refusedinnodedb/tests/wire/cases/sql_sequence_row_scope_refusals.rs(sourcetisengine = 'kv').INSERT INTO dst (id) SELECT upper(v) FROM kvsrcwrites only theidcolumn, sovis NULL by definition. It also puts a TEXT expression into a BIGINT key.If that returns
'HELLO', this issue can close with that case added as a wire test.