|
30 | 30 | }, |
31 | 31 | ) |
32 | 32 |
|
| 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 | + |
33 | 40 | try: |
34 | 41 | from great_expectations.compatibility.pyspark import types as PYSPARK_TYPES |
35 | 42 |
|
@@ -235,3 +242,28 @@ def test_include_unexpected_rows_sql(batch_for_datasource: Batch) -> None: |
235 | 242 | # Check that null values appear in the unexpected rows data (represented as None) |
236 | 243 | unexpected_rows_str = str(unexpected_rows_data) |
237 | 244 | 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