Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
varunmittal91 committed Dec 5, 2023
1 parent 0474309 commit 5237b41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions focus_validator/rules/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ def check_sql_query(df_groups, sql_query, column_alias):

# for the given indexes in false_indexes list, we are extracting the rows from the dataframe and
# add column_alias value to failure_case column and index to index column
failure_cases = df[df.index.isin(false_indexes)]
failure_cases["failure_case"] = df.apply(
lambda row: {column: row[column] for column in column_alias}, axis=1
)
failure_cases["failure_case"] = df.apply(
lambda row: ",".join(
[f"{column}:{row[column]}" for column in column_alias]
),
axis=1,
failure_cases = df[df.index.isin(false_indexes)].copy()
error_values = list(
[
",".join([f"{column}:{row[column]}" for column in column_alias])
for _, row in failure_cases.iterrows()
]
)
failure_cases.loc[:, "failure_case"] = error_values

raise SchemaError(
schema=pa.DataFrameSchema(),
Expand Down
2 changes: 1 addition & 1 deletion tests/data_loaders/test_null_value_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_null_value_from_csv_with_missing_value(self):
sample_data = pd.DataFrame([{"value": None}])

buffer = io.BytesIO()
sample_data.to_csv(buffer, index=False)
sample_data.to_csv(buffer, index=False, lineterminator="\n")

buffer.seek(0)
self.assertEqual(buffer.read(), b'value\n""\n')
Expand Down

0 comments on commit 5237b41

Please sign in to comment.