Skip to content

INSERT..SELECT with a kv-engine source silently NULLs expression cells #311

Description

@EnRaiha

Summary

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.

Evidence

  • SELECT 1 + 1 FROM kv returned an empty column until kv scan projections
    were fixed in feat(sql): evaluate sequence accessors in constant contexts and kv projections #307 (KvOp::Scan now carries projection + computed columns).
  • 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).

Related: #303, #307, #294

Reproduction

CREATE COLLECTION kvsrc (id BIGINT PRIMARY KEY, v TEXT) WITH (engine = 'kv');
INSERT INTO kvsrc (id, v) VALUES (1, 'hello');
CREATE COLLECTION dst (id BIGINT PRIMARY KEY, v TEXT) WITH (engine = 'document_schemaless');
INSERT INTO dst (id) SELECT upper(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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sqlParser, planner, SQL semanticsengine:kvKey-Value enginepriority:P2Scheduled, not urgentsev:3-mediumFeature wrong, but operational and a workaround existsstatus:confirmedReproduced by a maintainertype:bugA defect — broken, incorrect, or lost data

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions