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.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
- Run your transforms or extracts so the target table or file exists.
- Then run the GE checkpoint against it.
- Order the steps so quality checks always follow data production.
- run: dbt build # produce the tables first
- run: python validate.py # then Great Expectations validates themCorrect the batch request
Verify the table name, file path glob, or partition filter in the batch request matches real data in the CI environment.
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.