Skip to content
Latchkey

Great Expectations "Batch ... could not be retrieved" in CI

Great Expectations built a batch request but the datasource returned no batch: the table does not exist yet, the file glob matched nothing, or the query returned zero rows. Validation cannot run without a batch.

What this error means

GE raises an error that the batch could not be retrieved or that zero batches matched the batch request, often because transforms have not run in CI before the validation.

great_expectations
great_expectations.exceptions.exceptions.GreatExpectationsError:
The following BatchRequest returned no batch definitions: retrieved 0 batches.

Common causes

The target table or file does not exist yet

CI validates before the model or extract that produces the data has run, so the batch resolves to nothing.

The batch request pattern matches no data

A file glob, table name, or partition filter in the batch request does not match anything in the CI warehouse or filesystem.

How to fix it

Build the data before validating

  1. Run your transforms or extracts so the target table or file exists.
  2. Then run the GE checkpoint against it.
  3. Order the steps so quality checks always follow data production.
.github/workflows/ci.yml
- run: dbt build            # produce the tables first
- run: python validate.py   # then Great Expectations validates them

Correct the batch request

Verify the table name, file path glob, or partition filter in the batch request matches real data in the CI environment.

validate.py
batch_request = {
    "datasource_name": "warehouse",
    "data_asset_name": "public.orders",
}

How to prevent it

  • Sequence transforms before quality checks in the workflow.
  • Keep batch request patterns in sync with real table and file names.
  • Fail loudly on empty batches instead of silently passing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →