Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updates BigQuery hashbytes to use to_hex for row validations #400

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions data_validation/result_handlers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"""

from data_validation import consts
import pandas as pd


class TextResultHandler(object):
Expand All @@ -36,16 +35,6 @@ def print_formatted_(self, result_df):
Utility for printing formatted results
:param result_df
"""
# the text transformer chokes on bytestring results (e.g. SHA256) this
# dataframe slice is to remove the source and target values
mask = result_df["validation_type"] == consts.ROW_VALIDATION
row_result_df = result_df[mask]
other_result_df = result_df[~mask]
row_result_df["source_agg_value"] = None
row_result_df["target_agg_value"] = None
frames = [row_result_df, other_result_df]
result_df = pd.concat(frames)

if self.format == "text":
print(result_df.to_string(index=False))
elif self.format == "csv":
Expand Down
2 changes: 1 addition & 1 deletion third_party/ibis/ibis_addon/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def format_hashbytes_bigquery(translator, expr):
arg, how = expr.op().args
compiled_arg = translator.translate(arg)
if how == "sha256":
return f"SHA256({compiled_arg})"
return f"TO_HEX(SHA256({compiled_arg}))"
elif how == "farm_fingerprint":
return f"FARM_FINGERPRINT({compiled_arg})"
else:
Expand Down