Skip to content

Commit

Permalink
basic check of null-excepting
Browse files Browse the repository at this point in the history
  • Loading branch information
ADBond committed Jan 2, 2025
1 parent dd89373 commit 57bf701
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ def input_nodes_with_lat_longs():
n_rows = 1_000
lats = np.random.uniform(low=lat_low, high=lat_high, size=n_rows)
longs = np.random.uniform(low=long_low, high=long_high, size=n_rows)

# introduce a few nulls to check they do not interfere
lats[10] = None
lats[45] = None
longs[45] = None
longs[30] = None

# also include some names so we have a second comparison
names = np.random.choice(
_NAMES,
Expand Down
31 changes: 24 additions & 7 deletions tests/test_cll_ch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,38 @@
from splinkclickhouse.column_expression import ColumnExpression


def test_distance_in_km_level(api_info, input_nodes_with_lat_longs):
@mark.parametrize("not_null", [True, False])
def test_distance_in_km_level(api_info, input_nodes_with_lat_longs, not_null):
db_api = api_info["db_api_factory"]()

null_level_list = (
[]
if not_null
else [cll.Or(cll.NullLevel("latitude"), cll.NullLevel("longitude"))]
)

settings = SettingsCreator(
link_type="dedupe_only",
comparisons=[
cl.ExactMatch("name"),
cl.CustomComparison(
comparison_levels=[
cll.Or(cll.NullLevel("latitude"), cll.NullLevel("longitude")),
cll_ch.DistanceInKMLevel("latitude", "longitude", 10),
cll_ch.DistanceInKMLevel("latitude", "longitude", 50),
cll_ch.DistanceInKMLevel("latitude", "longitude", 100),
cll_ch.DistanceInKMLevel("latitude", "longitude", 200),
cll_ch.DistanceInKMLevel("latitude", "longitude", 500),
*null_level_list,
cll_ch.DistanceInKMLevel(
"latitude", "longitude", 10, not_null=not_null
),
cll_ch.DistanceInKMLevel(
"latitude", "longitude", 50, not_null=not_null
),
cll_ch.DistanceInKMLevel(
"latitude", "longitude", 100, not_null=not_null
),
cll_ch.DistanceInKMLevel(
"latitude", "longitude", 200, not_null=not_null
),
cll_ch.DistanceInKMLevel(
"latitude", "longitude", 500, not_null=not_null
),
cll.ElseLevel(),
],
output_column_name="latlong",
Expand Down

0 comments on commit 57bf701

Please sign in to comment.