-
Notifications
You must be signed in to change notification settings - Fork 148
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
Further br fixes #2106
Merged
Merged
Further br fixes #2106
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,12 @@ | |
|
||
import pandas as pd | ||
|
||
from .analyse_blocking import ( | ||
count_comparisons_from_blocking_rule_pre_filter_conditions, | ||
) | ||
from .blocking import BlockingRule | ||
from .blocking_rule_creator import BlockingRuleCreator | ||
from .blocking_rule_library import CustomRule, block_on | ||
from .input_column import InputColumn | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -64,30 +69,13 @@ def _generate_blocking_rule( | |
"""Generate a Splink blocking rule given a list of column names which | ||
are provided as as string""" | ||
|
||
# TODO: Refactor in Splink4 | ||
dialect = linker._sql_dialect | ||
|
||
module_mapping = { | ||
"presto": "splink.athena.blocking_rule_library", | ||
"duckdb": "splink.duckdb.blocking_rule_library", | ||
"postgres": "splink.postgres.blocking_rule_library", | ||
"spark": "splink.spark.blocking_rule_library", | ||
"sqlite": "splink.sqlite.blocking_rule_library", | ||
} | ||
|
||
if dialect not in module_mapping: | ||
raise ValueError(f"Unsupported SQL dialect: {dialect}") | ||
|
||
module_name = module_mapping[dialect] | ||
block_on_module = __import__(module_name, fromlist=["block_on"]) | ||
block_on = block_on_module.block_on | ||
|
||
if len(cols_as_string) == 0: | ||
return block_on("1") | ||
br: BlockingRuleCreator = CustomRule("1=1", linker._sql_dialect) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type hint was needed for mypy, without it you got an |
||
else: | ||
|
||
br = block_on(cols_as_string) | ||
br = block_on(*cols_as_string) | ||
|
||
return br | ||
return br.get_blocking_rule(linker._sql_dialect) | ||
|
||
|
||
def _search_tree_for_blocking_rules_below_threshold_count( | ||
|
@@ -165,8 +153,9 @@ def _search_tree_for_blocking_rules_below_threshold_count( | |
return results # All fields included, meaning we're at a leaf so exit recursion | ||
|
||
br = _generate_blocking_rule(linker, current_combination) | ||
comparison_count = ( | ||
linker._count_num_comparisons_from_blocking_rule_pre_filter_conditions(br) | ||
|
||
comparison_count = count_comparisons_from_blocking_rule_pre_filter_conditions( | ||
linker, br | ||
) | ||
|
||
already_visited.add(frozenset(current_combination)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved out of linker to reduce line count and so it can be more easily called from elsewhere