Skip to content

Commit d748463

Browse files
committed
Handle duplicate columns in schema validation report
1 parent dd5cdd0 commit d748463

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

pointblank/validate.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19069,16 +19069,33 @@ def _step_report_schema_in_order(
1906919069
dtype_exp = []
1907019070
dtype_exp_correct = []
1907119071

19072-
for i in range(len(exp_columns_dict)):
19072+
for i in range(len(expect_schema)):
1907319073
#
1907419074
# `col_name_exp` values
1907519075
#
1907619076

19077-
# The column name is the key in the dictionary, get the column name and
19078-
# append it to the `col_name_exp` list
19079-
col_name_exp.append(list(exp_columns_dict.keys())[i])
19077+
# Get the column name from expect_schema (which can have duplicates)
19078+
column_name_exp_i = expect_schema[i][0]
19079+
col_name_exp.append(column_name_exp_i)
1908019080

19081-
column_name_exp_i = col_name_exp[i]
19081+
# Check if this column exists in exp_columns_dict (it might not if it's a duplicate)
19082+
# For duplicates, we need to handle them specially
19083+
if column_name_exp_i not in exp_columns_dict:
19084+
# This is a duplicate or invalid column, mark it as incorrect
19085+
col_exp_correct.append(CROSS_MARK_SPAN)
19086+
19087+
# For dtype, check if there's a dtype specified in the schema
19088+
if len(expect_schema[i]) > 1:
19089+
dtype_value = expect_schema[i][1]
19090+
if isinstance(dtype_value, list):
19091+
dtype_exp.append(" | ".join(dtype_value))
19092+
else:
19093+
dtype_exp.append(str(dtype_value))
19094+
else:
19095+
dtype_exp.append("—")
19096+
19097+
dtype_exp_correct.append("—")
19098+
continue
1908219099

1908319100
#
1908419101
# `col_exp_correct` values

tests/snapshots/test_validate/test_comprehensive_validation_report_html_snap/comprehensive_validation_report.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,14 @@
13431343
</tr>
13441344
</tbody>
13451345

1346+
</table>
1347+
</div>
1348+
</div>
1349+
</details>
1350+
</td>
1351+
</tr>
1352+
1353+
</tfoot>
13461354

13471355
</table>
13481356

0 commit comments

Comments
 (0)