diff --git a/tablite/base.py b/tablite/base.py index e19cb8fc..d335a1f6 100644 --- a/tablite/base.py +++ b/tablite/base.py @@ -1683,7 +1683,9 @@ def display_dict(self, slice_=None, blanks=None, dtype=False): def datatype(col): # PRIVATE """creates label for column datatype.""" types = col.types() - if len(types) == 1: + if len(types) == 0: + typ = "empty" + elif len(types) == 1: dt, _ = types.popitem() typ = dt.__name__ else: diff --git a/tablite/core.py b/tablite/core.py index 45427333..c1d3d2a8 100644 --- a/tablite/core.py +++ b/tablite/core.py @@ -729,7 +729,7 @@ def column_select(self, cols: list[ColumnSelectorDict], tqdm=_tqdm, TaskManager= """ return _column_select(self, cols, tqdm, TaskManager) - def join(self, other, left_keys, right_keys, left_columns, right_columns, kind="inner", merge_keys=False, tqdm=_tqdm, pbar=None): + def join(self, other, left_keys, right_keys, left_columns=None, right_columns=None, kind="inner", merge_keys=False, tqdm=_tqdm, pbar=None): """ short-cut for all join functions. kind: 'inner', 'left', 'outer', 'cross' diff --git a/tablite/joins.py b/tablite/joins.py index 1189d2ed..907452a6 100644 --- a/tablite/joins.py +++ b/tablite/joins.py @@ -171,14 +171,6 @@ def _jointype_check(T, other, left_keys, right_keys, left_columns, right_columns if len(left_keys) != len(right_keys): raise ValueError(f"Keys do not have same length: \n{left_keys}, \n{right_keys}") - for L, R in zip(left_keys, right_keys): - Lcol, Rcol = T[L], other[R] - if not set(Lcol.types()).intersection(set(Rcol.types())): - left_types = tuple(t.__name__ for t in list(Lcol.types().keys())) - right_types = tuple(t.__name__ for t in list(Rcol.types().keys())) - e = f"Type mismatch: Left key '{L}' {left_types} will never match right keys {right_types}" - raise TypeError(e) - if not isinstance(left_columns, list) or not left_columns: raise TypeError("left_columns (list of strings) are required") if any(column not in T.columns for column in left_columns): diff --git a/tests/test_api_basics.py b/tests/test_api_basics.py index f5d941af..88afe28c 100644 --- a/tests/test_api_basics.py +++ b/tests/test_api_basics.py @@ -618,7 +618,7 @@ def test05_verify_show_table(): expected = """\ +===+=====+=====+=====+ | # | A | B | C | -|row|mixed|mixed|mixed| +|row|empty|empty|empty| +---+-----+-----+-----+ +===+=====+=====+=====+""" assert txt2 == expected diff --git a/tests/test_join.py b/tests/test_join.py index 20b7135e..d8fce75f 100644 --- a/tests/test_join.py +++ b/tests/test_join.py @@ -561,3 +561,21 @@ def test_small_page_size(): Config.PAGE_SIZE = original_page_size +def test_join_with_no_pages(): + A = Table({'A':[1,2,3], 'B':[]}) + A.show(dtype=True, blanks="") + + B = Table({'A':[1,2,3], 'B':[None,None,None]}) + B.show(dtype=True) + + C = Table({'A1': [1]}) + A1 = C.join(A, left_keys=['A1'], right_keys=['B']) + assert isinstance(A1, Table), "although nothing will match, the operation is still valid" + B1 = C.join(B, left_keys=['A1'], right_keys=['B']) + assert isinstance(B1, Table), "although nothing will match, the operation is still valid" + + AA = Table({'A':[1,2,3], 'B':[10,20,30]}) + BB = Table({'A1': [1,2,3], 'B1': [1,2,3]}) + CC = AA.join(BB, ['B'], ['B1']) + assert isinstance(CC, Table), "although nothing will match, the operation is still valid" + CC.show(dtype=True, blanks='')