def test_sampling_method__limit( test_cases_for_sql_data_connector_sqlite_execution_engine, ): execution_engine = test_cases_for_sql_data_connector_sqlite_execution_engine batch_data, batch_markers = execution_engine.get_batch_data_and_markers( batch_spec=SqlAlchemyDatasourceBatchSpec( { "table_name": "table_partitioned_by_date_column__A", "batch_identifiers": {}, "splitter_method": "_split_on_whole_table", "splitter_kwargs": {}, "sampling_method": "_sample_using_limit", "sampling_kwargs": {"n": 20}, } ) ) batch = Batch(data=batch_data) validator = Validator(execution_engine, batches=[batch]) assert len(validator.head(fetch_all=True)) == 20 assert not validator.expect_column_values_to_be_in_set( "date", value_set=["2020-01-02"] ).success
def test_sampling_method__limit( test_cases_for_sql_data_connector_sqlite_execution_engine, ): execution_engine = test_cases_for_sql_data_connector_sqlite_execution_engine batch_data, batch_markers = execution_engine.get_batch_data_and_markers( batch_spec=BatchSpec( { "table_name": "table_partitioned_by_date_column__A", "partition_definition": {}, "splitter_method": "_split_on_whole_table", "splitter_kwargs": {}, "sampling_method": "_sample_using_limit", "sampling_kwargs": {"n": 20}, } ) ) execution_engine.load_batch_data("__", batch_data) validator = Validator(execution_engine) assert len(validator.head(fetch_all=True)) == 20 assert ( validator.expect_column_values_to_be_in_set( "date", value_set=["2020-01-02"] ).success == False )
def test_sqlalchemy_source_templating(sqlitedb_engine): datasource = SqlAlchemyDatasource(engine=sqlitedb_engine, generators={ "foo": { "class_name": "QueryBatchKwargsGenerator" } }) generator = datasource.get_generator("foo") generator.add_query("test", "select 'cat' as ${col_name};") batch = datasource.get_batch(generator.build_batch_kwargs("test", query_parameters={'col_name': "animal_name"})) dataset = Validator(batch, expectation_suite=ExpectationSuite("test"), expectation_engine=SqlAlchemyDataset).get_dataset() res = dataset.expect_column_to_exist("animal_name") assert res.success is True res = dataset.expect_column_values_to_be_in_set('animal_name', ['cat']) assert res.success is True