Skip to content

Commit

Permalink
Audrius is a better programmer than me.
Browse files Browse the repository at this point in the history
  • Loading branch information
root-11 committed Feb 6, 2024
1 parent dea00d6 commit 804dce3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
4 changes: 3 additions & 1 deletion tablite/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tablite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 0 additions & 8 deletions tablite/joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def test05_verify_show_table():
expected = """\
+===+=====+=====+=====+
| # | A | B | C |
|row|mixed|mixed|mixed|
|row|empty|empty|empty|
+---+-----+-----+-----+
+===+=====+=====+=====+"""
assert txt2 == expected
Expand Down
18 changes: 18 additions & 0 deletions tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='')

0 comments on commit 804dce3

Please sign in to comment.