Skip to content

Commit

Permalink
update pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-packmoose authored and RobinL committed Sep 20, 2024
1 parent e2d6197 commit 73efaa7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions splink/internals/comparison_level_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,8 @@ def create_sql(self, sql_dialect: SplinkDialect) -> str:
sqlglot_dialect_name = sql_dialect.sqlglot_name

sqlglot_base_dialect_sql = """
LEAST(ARRAY_SIZE(___col____l), ARRAY_SIZE(___col____r))<>0
AND
ARRAY_SIZE(
ARRAY_INTERSECT(___col____l, ___col____r)) /
LEAST(ARRAY_SIZE(___col____l), ARRAY_SIZE(___col____r))
Expand Down
34 changes: 34 additions & 0 deletions tests/test_array_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,37 @@ def test_array_comparison_1(test_helpers, dialect):
ArrayIntersectAtSizes("postcode", [-1, 2]).get_comparison(
db_api.sql_dialect.sqlglot_name
)


# No SQLite - no array comparisons in library
@mark_with_dialects_excluding("sqlite")
def test_array_subset(test_helpers, dialect):
helper = test_helpers[dialect]
db_api = helper.extra_linker_args()["db_api"]

test_spec = ComparisonLevelTestSpec(
cll.ArraySubsetLevel("arr"),
tests=[
LiteralTestValues(
{"arr_l": ["A", "B", "C", "D"], "arr_r": ["A", "B", "C", "D"]},
expected_in_level=True,
),
LiteralTestValues(
{"arr_l": ["A", "B", "C", "D"], "arr_r": ["A", "B", "C", "Z"]},
expected_in_level=False,
),
LiteralTestValues(
{"arr_l": ["A", "B"], "arr_r": ["A", "B", "C", "D"]},
expected_in_level=True,
),
LiteralTestValues(
{"arr_l": ["A", "B", "C", "D"], "arr_r": ["X", "Y", "Z"]},
expected_in_level=False,
),
LiteralTestValues(
{"arr_l": [], "arr_r": ["X", "Y", "Z"]},
expected_in_level=False,
),
],
)
run_tests_with_args(test_spec, db_api)

0 comments on commit 73efaa7

Please sign in to comment.