Skip to content

Commit 0ef05d6

Browse files
Fix segfault on join with None (#422)
Fixes #353
2 parents 6f161de + 4acb9f7 commit 0ef05d6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/duckdb_py/pyrelation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,9 @@ static JoinType ParseJoinType(const string &type) {
11881188

11891189
unique_ptr<DuckDBPyRelation> DuckDBPyRelation::Join(DuckDBPyRelation *other, const py::object &condition,
11901190
const string &type) {
1191+
if (!other) {
1192+
throw InvalidInputException("No relation provided for join");
1193+
}
11911194

11921195
JoinType join_type;
11931196
string type_string = StringUtil::Lower(type);

tests/fast/api/test_join.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ def test_relational_join_with_condition(self):
4545
res = rel.fetchall()
4646
assert res == [(1, 2, 1, 3)]
4747

48+
def test_join_none_raises(self):
49+
con = duckdb.connect()
50+
rel = con.sql("SELECT 1 AS col1")
51+
52+
with pytest.raises(duckdb.InvalidInputException, match="No relation provided for join"):
53+
rel.join(None, "col1")
54+
4855
@pytest.mark.xfail(condition=True, reason="Selecting from a duplicate binding causes an error")
4956
def test_deduplicated_bindings(self, duckdb_cursor):
5057
duckdb_cursor.execute("create table old as select * from (values ('42', 1), ('21', 2)) t(a, b)")

0 commit comments

Comments
 (0)