Skip to content

Commit 7f02b87

Browse files
authored
Merge pull request #103 from pdet/full_out
Support full outer join
2 parents 5469b2e + 2239fb2 commit 7f02b87

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/from_substrait.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformJoinOp(const substrait::Rel &so
401401
case substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_SEMI:
402402
djointype = JoinType::SEMI;
403403
break;
404+
case substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_OUTER:
405+
djointype = JoinType::OUTER;
406+
break;
404407
default:
405408
throw InternalException("Unsupported join type");
406409
}

src/to_substrait.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ uint64_t DuckDBToSubstrait::RegisterFunction(const string &name, vector<::substr
568568
std::ostringstream error;
569569
// Casting Error Message
570570
error << "Could not find function \"" << function.function.GetName() << "\" with argument types: (";
571-
auto types = custom_functions.GetTypes(args_types);
571+
auto types = SubstraitCustomFunctions::GetTypes(args_types);
572572
for (idx_t i = 0; i < types.size(); i++) {
573573
error << "\'" << types[i] << "\'";
574574
if (i != types.size() - 1) {
@@ -912,6 +912,9 @@ substrait::Rel *DuckDBToSubstrait::TransformComparisonJoin(LogicalOperator &dop)
912912
case JoinType::SEMI:
913913
sjoin->set_type(substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_SEMI);
914914
break;
915+
case JoinType::OUTER:
916+
sjoin->set_type(substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_OUTER);
917+
break;
915918
default:
916919
throw InternalException("Unsupported join type " + JoinTypeToString(djoin.join_type));
917920
}

test/sql/test_join.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# name: test/sql/test_join.test
2+
# description: Test Join operators
3+
# group: [sql]
4+
5+
require substrait
6+
7+
statement ok
8+
PRAGMA enable_verification
9+
10+
statement ok
11+
CREATE table customer as select range c_custkey, range::VARCHAR c_name from range(10000);
12+
13+
# Test Full outer join
14+
statement ok
15+
CALL get_substrait('
16+
WITH raw_data as (SELECT * from customer),
17+
cte1 as (SELECT c_custkey as join_custkey, c_name from raw_data where c_custkey = 800),
18+
cte2 as (SELECT c_custkey as other_custkey, c_name from raw_data where c_custkey = 900)
19+
select * from cte1 full join cte2 on join_custkey = other_custkey;
20+
');

0 commit comments

Comments
 (0)