Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 0f2f1d4

Browse files
committed
diff_tables: Parameter 'algorithm' is now AUTO by default
1 parent b2b079c commit 0f2f1d4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

data_diff/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def diff_tables(
6363
# There may be many pools, so number of actual threads can be a lot higher.
6464
max_threadpool_size: Optional[int] = 1,
6565
# Algorithm
66-
algorithm: Algorithm = Algorithm.HASHDIFF,
66+
algorithm: Algorithm = Algorithm.AUTO,
6767
# Into how many segments to bisect per iteration (hashdiff only)
6868
bisection_factor: int = DEFAULT_BISECTION_FACTOR,
6969
# When should we stop bisecting and compare locally (in row count; hashdiff only)
@@ -94,7 +94,7 @@ def diff_tables(
9494
max_threadpool_size (int): Maximum size of each threadpool. ``None`` means auto.
9595
Only relevant when `threaded` is ``True``.
9696
There may be many pools, so number of actual threads can be a lot higher.
97-
algorithm (:class:`Algorithm`): Which diffing algorithm to use (`HASHDIFF` or `JOINDIFF`)
97+
algorithm (:class:`Algorithm`): Which diffing algorithm to use (`HASHDIFF` or `JOINDIFF`. Default=`AUTO`)
9898
bisection_factor (int): Into how many segments to bisect per iteration. (Used when algorithm is `HASHDIFF`)
9999
bisection_threshold (Number): Minimal row count of segment to bisect, otherwise download
100100
and compare locally. (Used when algorithm is `HASHDIFF`).
@@ -144,6 +144,9 @@ def diff_tables(
144144
segments = [t.new(**override_attrs) for t in tables] if override_attrs else tables
145145

146146
algorithm = Algorithm(algorithm)
147+
if algorithm == Algorithm.AUTO:
148+
algorithm = Algorithm.JOINDIFF if table1.database is table2.database else Algorithm.HASHDIFF
149+
147150
if algorithm == Algorithm.HASHDIFF:
148151
differ = HashDiffer(
149152
bisection_factor=bisection_factor,

0 commit comments

Comments
 (0)