Skip to main content
Version: 1.3.10

TableAsset

Signature

class great_expectations.datasource.fluent.sql_datasource.TableAsset(
*,
name: str,
type: typing.Literal['table'] = 'table',
id: <pydantic.v1.fields.DeferredType object at 0x7fed497a3bc0> = None,
order_by: <pydantic.v1.fields.DeferredType object at 0x7fed497a3c80> = None,
batch_metadata: <pydantic.v1.fields.DeferredType object at 0x7fed497a3dd0> = None,
batch_definitions: <pydantic.v1.fields.DeferredType object at 0x7fed497a3f80> = None,
table_name: str = '',
schema_name: typing.Optional[str] = None
)

A class representing a table from a SQL database

Parameters

NameDescription

table_name

The name of the database table to be added

schema_name

The name of the schema containing the database table to be added.

Methods

add_batch_definition_daily

Signature

add_batch_definition_daily(
name: str,
column: str,
sort_ascending: bool = True,
validate_batchable: bool = True
) → BatchDefinition

Adds a daily Batch Definition to this Data Asset

Parameters

NameDescription

name

The name of the Batch Definition to be added

column

The column name on which to partition the asset by day

sort_ascending

Boolean to indicate whether to sort ascending (default) or descending. When running a validation, we default to running the last Batch Definition if one is not explicitly specified.

Returns

TypeDescription

BatchDefinition

The added BatchDefinition object.

add_batch_definition_monthly

Signature

add_batch_definition_monthly(
name: str,
column: str,
sort_ascending: bool = True,
validate_batchable: bool = True
) → BatchDefinition

Adds a monthly Batch Definition to this Data Asset

Parameters

NameDescription

name

The name of the Batch Definition to be added

column

The column name on which to partition the asset by month

sort_ascending

Boolean to indicate whether to sort ascending (default) or descending. When running a validation, we default to running the last Batch Definition if one is not explicitly specified.

Returns

TypeDescription

BatchDefinition

The added BatchDefinition object.

add_batch_definition_whole_table

Signature

add_batch_definition_whole_table(
name: str
) → BatchDefinition

Adds a whole table Batch Definition to this Data Asset

Parameters

NameDescription

name

The name of the Batch Definition to be added

Returns

TypeDescription

BatchDefinition

The added BatchDefinition object.

add_batch_definition_yearly

Signature

add_batch_definition_yearly(
name: str,
column: str,
sort_ascending: bool = True,
validate_batchable: bool = True
) → BatchDefinition

Adds a yearly Batch Definition to this Data Asset

Parameters

NameDescription

name

The name of the Batch Definition to be added.

column

The column name on which to partition the asset by year.

sort_ascending

Boolean to indicate whether to sort ascending (default) or descending. When running a validation, we default to running the last Batch Definition if one is not explicitly specified.

Returns

TypeDescription

BatchDefinition

The added BatchDefinition object.

delete_batch_definition

Signature

delete_batch_definition(
name: str
)None

Delete a batch definition.

Parameters

NameDescription

name (str)

Name of the BatchDefinition to delete.

get_batch_definition

Signature

get_batch_definition(
name: str
) → great_expectations.core.batch_definition.BatchDefinition

Get a batch definition.

Parameters

NameDescription

name (str)

Name of the BatchDefinition to get.

Raises

TypeDescription

KeyError

If the BatchDefinition does not exist.

validate_batch_definition

Signature

validate_batch_definition(
partitioner: Union[great_expectations.core.partitioners.PartitionerColumnValue,
great_expectations.core.partitioners.PartitionerMultiColumnValue,
great_expectations.core.partitioners.PartitionerDividedInteger,
great_expectations.core.partitioners.PartitionerModInteger,
great_expectations.core.partitioners.ColumnPartitionerYearly,
great_expectations.core.partitioners.ColumnPartitionerMonthly,
great_expectations.core.partitioners.ColumnPartitionerDaily,
great_expectations.core.partitioners.PartitionerDatetimePart,
great_expectations.core.partitioners.PartitionerConvertedDatetime]
)None

Validates that the Batch Definition column is of a permissible type

This isn't meant to be called directly. This is called internally when a Batch Definition

is added. Data asset implementers can override this for their specific data asset.

Raises

TypeDescription

SqlAddBatchDefinitionError

The specified column to partition on is not of a permissible type for batching (ie date or datetime) or no data is present in this column.