Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Retrieve large result sets with pagination

Page through Semantic REST result sets larger than 50,000 records using limit, offset, and a deterministic order.

Your Semantic REST query returns more than 50,000 records, so you need to retrieve it in batches. Semantic REST queries are asynchronous: you submit the query, poll the statement until it completes, then fetch the result. This recipe adds limit, offset, and a deterministic order so each batch picks up exactly where the last one ended. The journey is submit a batch → poll the statement → retrieve the result → repeat with the next offset.

What this enables:

Prerequisites: a DataOS API token and the Data Product's API base URL. See Authentication.

Steps

1. Submit the first batch

Add limit, offset, and order to the POST request body:

  • limit defines the maximum number of records in each batch. Set it based on your application's throughput requirements.

  • offset defines where the batch begins.

  • order must stay the same across all batches.

The following request retrieves the first 50,000 records:

Paginated Semantic REST query
curl --request POST \
  'https://<DATAOS_FQDN>/vulcan/tenants/<DATAOS_TENANT_ID>/data-products/<DATAOS_TENANT_ID>-<resource-name>/api/v1/query/semantic/rest' \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer ${DATAOS_TOKEN}" \
  --data '{
    "query": {
      "measures": [
        "customer_profile.count"
      ],
      "dimensions": [
        "customer_profile.region_id"
      ],
      "order": {
        "customer_profile.region_id": "asc"
      },
      "limit": 50000,
      "offset": 0,
      "timezone": "UTC"
    }
  }'

2. Poll the statement

Each POST request returns a statement ID:

Poll the statement until the status becomes SUCCESS:

Keep polling while the status is ACCEPTED, QUEUED, or IN_PROGRESS.

3. Retrieve the result

Parquet downloads the complete result as a single file. limit, offset, and columns are ignored for the Parquet format. For large exports, use Parquet instead of retrieving many JSON batches.

4. Fetch the next batch

Keep the same order and increase only the offset, then repeat steps 1 to 3:

Continue until a returned batch contains fewer records than the requested limit.

Troubleshooting

Issue
Resolution

The statement status is FAILED

Inspect the error field in the statement response.

Batches contain duplicate records, or records are missing

Use the same order in every request and change only the offset between batches.

limit or offset has no effect on the result

The Parquet format ignores limit, offset, and columns and returns the complete result. Use JSON to retrieve batches.

Outcome

You retrieved a result set larger than 50,000 records in consistent batches, with no duplicates or gaps, or downloaded it as a single Parquet file.

References

Last updated

Was this helpful?