Skip to main content
Version: 1.3.2

Batch

class great_expectations.datasource.fluent.interfaces.Batch(datasource: Datasource, data_asset: DataAsset, batch_request: BatchRequest, data: BatchData, batch_markers: BatchMarkers, batch_spec: BatchSpec, batch_definition: LegacyBatchDefinition, metadata: Dict[str, Any] | None = None)#

This represents a batch of data.

This is usually not the data itself but a hook to the data on an external datastore such as a spark or a sql database. An exception exists for pandas or any in-memory datastore.

Methods

columns() List[str]#

Return column names of this Batch.

Returns

List[str]

head(n_rows: pydantic.v1.types.StrictInt = 5, fetch_all: pydantic.v1.types.StrictBool = False) great_expectations.datasource.fluent.interfaces.HeadData#

Return the first n rows of this Batch.

This method returns the first n rows for the Batch based on position.

For negative values of n_rows, this method returns all rows except the last n rows.

If n_rows is larger than the number of rows, this method returns all rows.

Parameters

n_rows: The number of rows to return from the Batch. fetch_all: If True, ignore n_rows and return the entire Batch.

Returns

HeadData

validate(expect: Expectation, *, result_format: ResultFormatUnion = 'DEFAULT_RESULT_FORMAT', expectation_parameters: Optional[SuiteParameterDict] = 'None') ExpectationValidationResult#

validate(expect: ExpectationSuite, *, result_format: ResultFormatUnion = 'DEFAULT_RESULT_FORMAT', expectation_parameters: Optional[SuiteParameterDict] = 'None') ExpectationSuiteValidationResult

Validate the Batch using the provided Expectation or Expectation Suite.

Parameters
  • expect – The Expectation or Expectation Suite to validate.

  • result_format – The format to return the validation results in.

  • expectation_parameters – A dictionary of parameters values for any expectations using parameterized values (the $PARAMETER syntax). The keys are the parameter names and the values are the values to be used for this validation run.

Returns

An ExpectationValidationResult or ExpectationSuiteValidationResult object.

Raises

ValueError – If the expect argument is not an Expectation or an ExpectationSuite.