GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — duckdb: fix unknown column error for the rowid pseudo-column by RyoKusnadi · Pull Request #4678 · sqlc-dev/sqlc

Conversation

@RyoKusnadi

@RyoKusnadi RyoKusnadi commented Nov 6, 2026

Copy link
Copy Markdown

Problem: On the DuckDB engine, rowid fails with unknown column "rowid" in a SELECT list, as p.rowid, in WHERE, and in ORDER BY. DuckDB accepts all of these.

How it happens: Any DuckDB query that uses rowid on a table from schema.sql hits it. The table has no declared rowid column, and the engine only knew declared columns.

Steps to reproduce: Use the schema and queries from the issue (SELECT rowid, id FROM plan, WHERE rowid = $1) with engine: duckdb, then run sqlc generate.

Expected: Code is generated, with rowid as a nullable BIGINT (what DESCRIBE reports).
Actual: unknown column "rowid".

Cause: convertCreateTableInfo in internal/engine/duckdb/convert.go only emitted the declared columns. SQLite's fts5 hidden columns already use ColumnDef.IsHidden for "resolves by name, not in * or models". The DuckDB side never used it.

Fix: Add a hidden nullable bigint rowid column to every CREATE TABLE. Star expansion and the generated model stay the same. If the table declares its own rowid column, that one wins and nothing is added.

Scope: CREATE TABLE ... AS and views get no rowid. I haven't checked whether DuckDB exposes it for them. I did not touch #4677 (table alias as a value) or #4659 (table functions).

Testing: New case internal/endtoend/testdata/duckdb_rowid (select, qualified, WHERE, ORDER BY, SELECT * skips rowid, user-declared rowid). It needs no database. Before the fix it fails with the four errors from the issue. After: go test -C internal/endtoend -run 'TestReplay/base' . passes. go vet and gofmt are clean on the duckdb package. I did not run the full suite or the tests that need PostgreSQL/MySQL or a live DuckDB.

Environment: fix/duckdb-rowid-column @ 5d94812, go1.27.1, darwin/arm64.

Fixes #4676

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Jyrno42 reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@RyoKusnadi
duckdb: resolve the rowid pseudo-column
5d94812
Signed-off-by: Ryo Kusnadi <[email protected]>
@RyoKusnadi RyoKusnadi mentioned this pull request Nov 6, 2026
duckdb: the rowid pseudo-column is an unknown column #4676
Open
@RyoKusnadi

RyoKusnadi commented Nov 8, 2026

Copy link
Copy Markdown
Author

Closing this for now, happy to reopen if it's useful.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@RyoKusnadi RyoKusnadi closed this Nov 8, 2026
@RyoKusnadi
RyoKusnadi deleted the fix/duckdb-rowid-column branch November 8, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

duckdb: the rowid pseudo-column is an unknown column

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@RyoKusnadi
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.