Repository navigation
duckdb: resolve the rowid pseudo-column - #4721
Closed
kyleconroy wants to merge 1 commit into
Closed
kyleconroy wants to merge 1 commit into
kyleconroy wants to merge 1 commit into
Conversation
Every DuckDB base table offers a rowid that a query can select, filter on and order by. The converter now adds it to each table as a hidden, nullable BIGINT column, the way the SQLite engine adds the hidden columns of an fts5 table, so it resolves by name but stays out of star expansions, INSERT targets and the table's model. A table that declares its own rowid keeps that column. Fixes #4676 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LuRZ4JY6kCxkjBm6hN7Lf3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Kyle · project thread
Fixes #4676.
Every DuckDB base table has a
rowidpseudo-column, but the engine only knew the columns a table declares, soSELECT rowid ...,WHERE rowid = $1andORDER BY rowidall failed withunknown column "rowid".Change
convertCreateTableInfoaddsrowidto each table as a hiddenBIGINTcolumn, the same way the SQLite engine adds the hidden columns of an fts5 table (IsHiddenon theColumnDef). The core catalog then resolves it by name while keeping it out of star expansions,INSERTtargets without a column list, and the table's model. It is nullable because that is what DuckDB'sDESCRIBEreports. A table that declares its ownrowidcolumn keeps that column.CREATE TABLE ... ASis unchanged.Tests
Adds the analysis-only case
analyze_rowid/duckdb. It covers bare and qualifiedrowid, arowidparameter,SELECT *withoutrowid,INSERTwithout a column list,DELETE ... RETURNING *, and a table that declares its ownrowid. The case fails onmainwith the errors from the issue.TestReplay/basepasses, and the opt-incorecontext shows the same failures as onmain. I couldn't run the goldeneye DuckDB check here, because the DuckDB CLI download is blocked from this environment.Relation to #4697
#4697 by @ruziba3vich takes the same approach in the converter, and this PR keeps that design. The difference is the test: this PR covers the fix with an
analyzecase instead of a generated-Go golden, since only the analysis result matters here. TheUPDATEquery from #4697's case is left out. If this merges, #4697 can be closed as superseded, with credit to its author.Generated by Claude Code