Skip to main content
Version: 0.18.9

QueryAsset

class great_expectations.datasource.fluent.sql_datasource.QueryAsset(*, name: str, type: Literal['query'] = 'query', id: Optional[uuid.UUID] = None, order_by: List[great_expectations.datasource.fluent.interfaces.Sorter] = None, batch_metadata: Dict[str, Any] = None, splitter: Optional[Union[great_expectations.datasource.fluent.sql_datasource.SplitterColumnValue, great_expectations.datasource.fluent.sql_datasource.SplitterMultiColumnValue, great_expectations.datasource.fluent.sql_datasource.SplitterDividedInteger, great_expectations.datasource.fluent.sql_datasource.SplitterModInteger, great_expectations.datasource.fluent.sql_datasource.SplitterYear, great_expectations.datasource.fluent.sql_datasource.SplitterYearAndMonth, great_expectations.datasource.fluent.sql_datasource.SplitterYearAndMonthAndDay, great_expectations.datasource.fluent.sql_datasource.SplitterDatetimePart]] = None, query: str)#

add_splitter_column_value(column_name: str) Self#

Associates a column value splitter with this sql asset. :param column_name: A column name of the column to split on.

Returns

This sql asset so we can use this method fluently.

add_splitter_datetime_part(column_name: str, datetime_parts: List[str]) Self#

Associates a datetime part splitter with this sql asset. :param column_name: Name of the date column where parts will be parsed out. :param datetime_parts: A list of datetime parts to split on, specified as DatePart objects or as their string equivalent e.g. “year”, “month”, “week”, “day”, “hour”, “minute”, or “second”

Returns

This sql asset so we can use this method fluently.

add_splitter_divided_integer(column_name: str, divisor: int) Self#

Associates a divided integer splitter with this sql asset. :param column_name: A column name of the column to split on. :param divisor: The divisor to use when splitting.

Returns

This sql asset so we can use this method fluently.

add_splitter_mod_integer(column_name: str, mod: int) Self#

Associates a mod integer splitter with this sql asset. :param column_name: A column name of the column to split on. :param mod: The mod to use when splitting.

Returns

This sql asset so we can use this method fluently.

add_splitter_multi_column_values(column_names: list[str]) Self#

Associates a multi column value splitter with this sql asset. :param column_names: A list of column names to split on.

Returns

This sql asset so we can use this method fluently.

add_splitter_year(column_name: str) Self#

Associates a year splitter with this sql data asset. :param column_name: A column name of the date column where year and month will be parsed out.

Returns

This sql asset so we can use this method fluently.

add_splitter_year_and_month(column_name: str) Self#

Associates a year, month splitter with this sql asset. :param column_name: A column name of the date column where year and month will be parsed out.

Returns

This sql asset so we can use this method fluently.

add_splitter_year_and_month_and_day(column_name: str) Self#

Associates a year, month, day splitter with this sql asset. :param column_name: A column name of the date column where year and month will be parsed out.

Returns

This sql asset so we can use this method fluently.

build_batch_request(options: Optional[BatchRequestOptions] = None, batch_slice: Optional[BatchSlice] = None) BatchRequest#

A batch request that can be used to obtain batches for this DataAsset.

Parameters
  • options – A dict that can be used to filter the batch groups returned from the asset. The dict structure depends on the asset type. The available keys for dict can be obtained by calling batch_request_options.

  • batch_slice – A python slice that can be used to limit the sorted batches by index. e.g. batch_slice = “[-5:]” will request only the last 5 batches after the options filter is applied.

Returns

A BatchRequest object that can be used to obtain a batch list from a Datasource by calling the get_batch_list_from_batch_request method.