MCPcopy Create free account
hub / github.com/apache/arrow / test_joins

Function test_joins

python/pyarrow/tests/test_exec_plan.py:103–136  ·  view source on GitHub ↗
(jointype, expected, use_threads, coalesce_keys, use_datasets)

Source from the content-addressed store, hash-verified

101@pytest.mark.parametrize("use_datasets",
102 [False, pytest.param(True, marks=pytest.mark.dataset)])
103def test_joins(jointype, expected, use_threads, coalesce_keys, use_datasets):
104 # Allocate table here instead of using parametrize
105 # this prevents having arrow allocated memory forever around.
106 expected = pa.table(expected)
107
108 t1 = pa.Table.from_pydict({
109 "colA": [1, 2, 6],
110 "col2": ["a", "b", "f"]
111 })
112
113 t2 = pa.Table.from_pydict({
114 "colB": [99, 2, 1],
115 "col3": ["Z", "B", "A"]
116 })
117
118 if use_datasets:
119 t1 = ds.dataset([t1])
120 t2 = ds.dataset([t2])
121
122 r = _perform_join(jointype, t1, "colA", t2, "colB",
123 use_threads=use_threads, coalesce_keys=coalesce_keys)
124 r = r.combine_chunks()
125 if "right" in jointype:
126 r = r.sort_by("colB")
127 else:
128 r = r.sort_by("colA")
129 if coalesce_keys:
130 if jointype in ("inner", "left outer"):
131 expected = expected.drop(["colB"])
132 elif jointype == "right outer":
133 expected = expected.drop(["colA"])
134 elif jointype == "full outer":
135 expected = expected.drop(["colB"]).set_column(0, "colA", [[1, 2, 6, 99]])
136 assert r == expected
137
138
139def test_table_join_collisions():

Callers

nothing calls this directly

Calls 1

_perform_joinFunction · 0.90

Tested by

no test coverage detected