diff --git a/src/duckdb_py/pyrelation.cpp b/src/duckdb_py/pyrelation.cpp index 9ee7c459..35e33786 100644 --- a/src/duckdb_py/pyrelation.cpp +++ b/src/duckdb_py/pyrelation.cpp @@ -1188,6 +1188,9 @@ static JoinType ParseJoinType(const string &type) { unique_ptr DuckDBPyRelation::Join(DuckDBPyRelation *other, const py::object &condition, const string &type) { + if (!other) { + throw InvalidInputException("No relation provided for join"); + } JoinType join_type; string type_string = StringUtil::Lower(type); diff --git a/tests/fast/api/test_join.py b/tests/fast/api/test_join.py index be311ec0..3aebb630 100644 --- a/tests/fast/api/test_join.py +++ b/tests/fast/api/test_join.py @@ -45,6 +45,13 @@ def test_relational_join_with_condition(self): res = rel.fetchall() assert res == [(1, 2, 1, 3)] + def test_join_none_raises(self): + con = duckdb.connect() + rel = con.sql("SELECT 1 AS col1") + + with pytest.raises(duckdb.InvalidInputException, match="No relation provided for join"): + rel.join(None, "col1") + @pytest.mark.xfail(condition=True, reason="Selecting from a duplicate binding causes an error") def test_deduplicated_bindings(self, duckdb_cursor): duckdb_cursor.execute("create table old as select * from (values ('42', 1), ('21', 2)) t(a, b)")