def get_table_columns_metric( engine: ExecutionEngine) -> [MetricConfiguration, dict]: resolved_metrics: dict = {} results: dict table_column_types_metric: MetricConfiguration = MetricConfiguration( metric_name="table.column_types", metric_domain_kwargs=dict(), metric_value_kwargs={ "include_nested": True, }, metric_dependencies=None, ) results = engine.resolve_metrics( metrics_to_resolve=(table_column_types_metric, )) resolved_metrics.update(results) table_columns_metric: MetricConfiguration = MetricConfiguration( metric_name="table.columns", metric_domain_kwargs=dict(), metric_value_kwargs=None, metric_dependencies={ "table.column_types": table_column_types_metric, }, ) results = engine.resolve_metrics( metrics_to_resolve=(table_columns_metric, ), metrics=resolved_metrics) resolved_metrics.update(results) return table_columns_metric, resolved_metrics
def test_add_column_row_condition_with_unsupported_conditions(): e = ExecutionEngine() # Ensuring that an attempt to filter nans within base class yields an error with pytest.raises(GreatExpectationsError) as error: new_domain_kwargs = e.add_column_row_condition({}, "a", filter_nan=True) # Having a pre-existing row condition should result in an error, as we should not be updating it with pytest.raises(GreatExpectationsError) as error: new_domain_kwargs = e.add_column_row_condition( {"column": "a", "row_condition": "col(a) == 2"} ) # Testing that error raised when column not given with pytest.raises(AssertionError) as error: new_domain_kwargs = e.add_column_row_condition({})
def test_add_column_row_condition(): e = ExecutionEngine() # Checking that adding a simple column row condition is functional new_domain_kwargs = e.add_column_row_condition({}, "a") assert new_domain_kwargs == { "condition_parser": "great_expectations__experimental__", "row_condition": 'col("a").notnull()', } # Ensuring that this also works when formatted differently new_domain_kwargs = e.add_column_row_condition({"column": "a"}) assert new_domain_kwargs == { "column": "a", "condition_parser": "great_expectations__experimental__", "row_condition": 'col("a").notnull()', } # Ensuring that everything still works if a row condition of None given new_domain_kwargs = e.add_column_row_condition({ "column": "a", "row_condition": None }) assert new_domain_kwargs == { "column": "a", "row_condition": None, "condition_parser": "great_expectations__experimental__", "row_condition": 'col("a").notnull()', } # Identity case new_domain_kwargs = e.add_column_row_condition({}, "a", filter_null=False) assert new_domain_kwargs == {}