feat: fetch results beyond the old 50k row cap#25
Open
jpetey75 wants to merge 1 commit into
Open
Conversation
The SDK hard-rejected any limit above 50,000, but 50k was never the real API cap — it was a stale number (the actual cap is the server's configurable `query.maxLimit`, e.g. 100,000 on Cloud, exposed via /api/v1/health). - `Client.get_query_limits()` discovers the instance's `query` config (maxLimit, maxPageSize, ...) from /api/v1/health, cached per client. - `Query.execute()` now rejects only limits < 1 locally, and validates larger limits against the discovered `maxLimit` — raising a clear ValueError instead of letting the server silently clamp and return a truncated result. - Large fetches page at the instance's `maxPageSize` (bounded by the requested limit) instead of a hard-coded 500, cutting round-trips ~5x. - Pagination now derives the page count from `total_results` and a single uniform page size, fixing a latent row-skip bug when a non-default page size was used. maxLimit / maxPageSize values verified against the live instance /health. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Closes #19
Problem
Query.execute()hard-rejected any limit above 50,000:But 50k was never the real API cap. Verification against Lightdash source + the live instance showed the actual ceiling is the server's configurable
query.maxLimit(default 5000, Cloud: 100000), exposed via/api/v1/health.50000is just a stale number (it's a CLI default elsewhere in Lightdash).So the old check both blocked valid queries (50k–100k) and, had we naively "removed the cap", would have let the server silently clamp and return a truncated result — the worst outcome for data extraction.
Change
Client.get_query_limits()— discovers the instance's query config (maxLimit,maxPageSize, …) from/api/v1/health, cached per client.Query.execute()rejects onlylimit < 1locally, then validates larger limits against the discoveredmaxLimit, raising a clearValueErrorrather than letting the server silently truncate. Fails open (lets the server enforce) if/healthis unreachable.maxPageSize(bounded by the requested limit) instead of a hard-coded 500, cutting round-trips ~5×.total_resultsand a single uniform page size, so changing page size can never skip or duplicate rows.Scope
Per discussion, this respects the query endpoint's
maxLimit. Pulling result sets larger than that (millions of rows) needs the separate CSV/download-export endpoint — I'll open a follow-up issue for that.Verification
query.maxLimit = 100000,maxPageSize = 2500confirmed from the live instance/api/v1/health.Tests
tests/test_row_limit.py(13 new): below-1 rejection, over-maxLimitrejection (no query submitted), 50k–100k now allowed, fail-open when/healtherrors, page size =maxPageSizebounded by limit, and pagination consistency (all rows returned exactly once, every page fetched at the same size). Full unit suite green (90 passed).🤖 Generated with Claude Code