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: Row validation optimization to avoid select all columns #599

Merged
merged 1 commit into from
Oct 10, 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
14 changes: 11 additions & 3 deletions data_validation/query_builder/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def compile_calculated_fields(self, table, n=0):
# else:
# return [field.compile(table) for field in self.calculated_fields]

def compile(self, data_client, schema_name, table_name):
def compile(self, validation_type, data_client, schema_name, table_name):
"""Return an Ibis query object
Args:
Expand All @@ -486,8 +486,16 @@ def compile(self, data_client, schema_name, table_name):
calc_table = calc_table.mutate(
self.compile_calculated_fields(calc_table, n)
)
if self.comparison_fields:
calc_table = calc_table.mutate(self.compile_comparison_fields(calc_table))

if validation_type == consts.ROW_VALIDATION:
nehanene15 marked this conversation as resolved.
Show resolved Hide resolved
calc_table = calc_table.projection(
nehanene15 marked this conversation as resolved.
Show resolved Hide resolved
self.compile_comparison_fields(calc_table)
)
else:
if self.comparison_fields:
calc_table = calc_table.mutate(
self.compile_comparison_fields(calc_table)
)
compiled_filters = self.compile_filter_fields(calc_table)
filtered_table = (
calc_table.filter(compiled_filters) if compiled_filters else calc_table
Expand Down
4 changes: 2 additions & 2 deletions data_validation/validation_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def get_source_query(self):
f"Input custom query type: {self.config_manager.custom_query_type}"
)
else:
query = self.source_builder.compile(**source_config)
query = self.source_builder.compile(self.validation_type, **source_config)
if self.verbose:
logging.info(source_config)
logging.info("-- ** Source Query ** --")
Expand Down Expand Up @@ -427,7 +427,7 @@ def get_target_query(self):
f"Input custom query type: {self.config_manager.custom_query_type}"
)
else:
query = self.target_builder.compile(**target_config)
query = self.target_builder.compile(self.validation_type, **target_config)
if self.verbose:
logging.info(target_config)
logging.info("-- ** Target Query ** --")
Expand Down