Title: client.query.sql() silently truncates at 5,000 rows — should auto-paginate · Issue #157 · microsoft/PowerPlatform-DataverseClient-Python · GitHub
Open Graph Title: client.query.sql() silently truncates at 5,000 rows — should auto-paginate · Issue #157 · microsoft/PowerPlatform-DataverseClient-Python
X Title: client.query.sql() silently truncates at 5,000 rows — should auto-paginate · Issue #157 · microsoft/PowerPlatform-DataverseClient-Python
Description: Problem client.query.sql() sends a single GET /{entity_set}?sql=
Open Graph Description: Problem client.query.sql() sends a single GET /{entity_set}?sql=
X Description: Problem client.query.sql() sends a single GET /{entity_set}?sql=<query> and returns whatever the server responds with. The Dataverse Web API default page size is 5,000 rows. If the query matc...
Opengraph URL: https://github.com/microsoft/PowerPlatform-DataverseClient-Python/issues/157
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"client.query.sql() silently truncates at 5,000 rows — should auto-paginate","articleBody":"## Problem\n\n`client.query.sql()` sends a single `GET /{entity_set}?sql=\u003cquery\u003e` and returns whatever the server responds with. The Dataverse Web API default page size is 5,000 rows. If the query matches more than 5,000 rows, **results are silently truncated** — no error, no warning.\n\nThis is inconsistent with the rest of the SDK:\n- `client.records.get()` — auto-paginates via `@odata.nextLink`, returns all results\n- `client.dataframe.get()` — auto-paginates, consolidates into a single DataFrame\n\n`client.query.sql()` is the only read method that silently drops data.\n\n## Observed behavior\n\n```python\n# Table has 136,590 rows\nresults = client.query.sql(\"SELECT srcid FROM prefix_ballbyball\")\nlen(results) # → 5000 (silently truncated, no error)\n```\n\nThe user gets 5,000 rows and has no way to know 131,590 rows are missing.\n\n## Expected behavior\n\n`client.query.sql()` should follow `@odata.nextLink` in the response and return all matching rows, consistent with `records.get()` and `dataframe.get()`.\n\n## Proposed fix\n\nCheck for `@odata.nextLink` in the response from `_query_sql()` and continue fetching pages until exhausted:\n\n```python\ndef _query_sql(self, sql: str) -\u003e list[dict[str, Any]]:\n # ... existing validation ...\n url = f\"{self.api}/{entity_set}\"\n params = {\"sql\": sql}\n all_rows = []\n \n r = self._request(\"get\", url, params=params)\n body = r.json() if r.text else {}\n all_rows.extend(body.get(\"value\", []))\n \n next_link = body.get(\"@odata.nextLink\")\n while next_link:\n r = self._request(\"get\", next_link)\n body = r.json() if r.text else {}\n all_rows.extend(body.get(\"value\", []))\n next_link = body.get(\"@odata.nextLink\")\n \n return all_rows\n```\n\nAlternatively, return a page iterator consistent with `records.get()` — but this would change the return type from `list[Record]` to `Iterable[list[Record]]`.\n\n## Impact\n\nAny user querying a table with \u003e5,000 rows via `client.query.sql()` is getting silently truncated results today. The `?sql=` parameter is commonly used for filtered reads and its utility would increase significantly if it could return full result sets.\n\n## Context\n\nDiscovered during end-to-end testing of a 21-table cricket dataset import (297K total records). After import, analytical queries via `client.query.sql()` returned only 5,000 of 136,590 rows from the largest table, producing incorrect aggregation results.","author":{"url":"https://github.com/suyask-msft","@type":"Person","name":"suyask-msft"},"datePublished":"2026-04-06T03:32:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/157/PowerPlatform-DataverseClient-Python/issues/157"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:94feaa30-f961-250b-304c-a993187d5b57 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B20A:298211:1B85B:25127:6A4D4FA6 |
| html-safe-nonce | 051e2eade239d6ce8eaeb0271184e9cfdf087409bfac1d27b11569dbb1ec827a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjBBOjI5ODIxMToxQjg1QjoyNTEyNzo2QTRENEZBNiIsInZpc2l0b3JfaWQiOiIyMzE4ODQ3MzM4NzQ1Nzc4MDg2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a86b37337ac8817df181ab2e74a6a8aa78eedd7ada80d8b97f97130a11d674a0 |
| hovercard-subject-tag | issue:4209369428 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/PowerPlatform-DataverseClient-Python/157/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1b9c0b22476f3b912618b515ff676cd6659a890e7a9c57633dbef6b2cf47901d/microsoft/PowerPlatform-DataverseClient-Python/issues/157 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1b9c0b22476f3b912618b515ff676cd6659a890e7a9c57633dbef6b2cf47901d/microsoft/PowerPlatform-DataverseClient-Python/issues/157 |
| og:image:alt | Problem client.query.sql() sends a single GET /{entity_set}?sql= |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | suyask-msft |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/PowerPlatform-DataverseClient-Python git https://github.com/microsoft/PowerPlatform-DataverseClient-Python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 1042273116 |
| octolytics-dimension-repository_nwo | microsoft/PowerPlatform-DataverseClient-Python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1042273116 |
| octolytics-dimension-repository_network_root_nwo | microsoft/PowerPlatform-DataverseClient-Python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fc8347865a14e2ec811533d68f929cf4e0ec19 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width