Skip to content

Commit 61393ca

Browse files
chay0112Chaitanya Vemulakondajoshua-stauffer
authored
[CONTRIB] Include unexpected_index_column_names in ExpectColumnValuesToNotBeNull results (#11513)
Co-authored-by: Chaitanya Vemulakonda <cvemulakonda@Chaitanyas-MacBook-Pro.local> Co-authored-by: Joshua Stauffer <66793731+joshua-stauffer@users.noreply.github.com>
1 parent faf66a4 commit 61393ca

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

great_expectations/expectations/core/expect_column_values_to_not_be_null.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,5 +438,6 @@ def _validate(
438438
unexpected_index_query=metrics.get(
439439
f"{self.map_metric}.{SummarizationMetricNameSuffixes.UNEXPECTED_INDEX_QUERY.value}"
440440
),
441+
unexpected_index_column_names=parsed_result_format.get("unexpected_index_column_names"),
441442
unexpected_rows=unexpected_rows,
442443
)

tests/integration/data_sources_and_expectations/expectations/test_expect_column_values_to_not_be_null.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
},
3131
)
3232

33+
IDX_DATA = pd.DataFrame(
34+
{
35+
"customer_id": [1, 2, 3, 4, 5],
36+
"email": ["a@x.com", "b@x.com", "c@x.com", "d@x.com", None],
37+
}
38+
)
39+
3340
try:
3441
from great_expectations.compatibility.pyspark import types as PYSPARK_TYPES
3542

@@ -235,3 +242,28 @@ def test_include_unexpected_rows_sql(batch_for_datasource: Batch) -> None:
235242
# Check that null values appear in the unexpected rows data (represented as None)
236243
unexpected_rows_str = str(unexpected_rows_data)
237244
assert "None" in unexpected_rows_str or "null" in unexpected_rows_str.lower()
245+
246+
247+
@parameterize_batch_for_data_sources(
248+
data_source_configs=JUST_PANDAS_DATA_SOURCES,
249+
data=IDX_DATA,
250+
)
251+
def test_unexpected_index_column_names(batch_for_datasource: Batch) -> None:
252+
"""
253+
Verify that when `unexpected_index_column_names` is requested via result_format,
254+
ExpectColumnValuesToNotBeNull includes it in the result payload.
255+
"""
256+
expectation = gxe.ExpectColumnValuesToNotBeNull(column="email")
257+
258+
result = batch_for_datasource.validate(
259+
expectation,
260+
result_format={
261+
"result_format": "COMPLETE",
262+
"unexpected_index_column_names": ["customer_id"],
263+
},
264+
)
265+
266+
assert not result.success
267+
result_dict = result["result"]
268+
assert "unexpected_index_column_names" in result_dict
269+
assert result_dict["unexpected_index_column_names"] == ["customer_id"]

0 commit comments

Comments
 (0)