Skip to content

duckdb: preserve OFFSET parameters with a percentage LIMIT - #4701

Open
1akashkalita wants to merge 1 commit into
sqlc-dev:mainfrom
1akashkalita:codex/duckdb-percent-offset
Open

1akashkalita wants to merge 1 commit into
sqlc-dev:mainfrom
1akashkalita:codex/duckdb-percent-offset

Conversation

@1akashkalita

Copy link
Copy Markdown

On main, sqlc drops the offset parameter from this DuckDB query:

-- name: Page :many
SELECT id FROM readings ORDER BY id LIMIT 50% OFFSET $1;

sqlc analyze reports an empty parameter list. The generated Go method calls QueryContext without an argument for $1. DuckDB accepts the query and expects the offset at execution time.

The DuckDB converter skips the entire limit modifier when the limit is a percentage. This change narrows that check to the limit count so the offset goes through the existing row-offset conversion. The end-to-end regression checks that the analyzer reports parameter 1.

I reproduced the missing argument on main, exercised the prepared query in DuckDB 1.4.1, and verified the generated Go method forwards its offset after the fix. The regression failed on main and passed with this change. The base replay suite and the core, DuckDB engine and compiler package tests passed with Go 1.26.5.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant