Skip to content

Commit

Permalink
Adjustment to see if this PoC works properly after some PR Requests
Browse files Browse the repository at this point in the history
  • Loading branch information
pdet committed Sep 3, 2024
1 parent 359be4e commit 73b072a
Show file tree
Hide file tree
Showing 5 changed files with 671 additions and 740 deletions.
12 changes: 7 additions & 5 deletions src/from_substrait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformJoinOp(const substrait::Rel &so
case substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_LEFT_SEMI:
djointype = JoinType::SEMI;
break;
case substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_MARK:
case substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_LEFT_MARK:
djointype = JoinType::MARK;
break;
case substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_RIGHT_SEMI:
Expand All @@ -439,7 +439,7 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformDelimJoinOp(const substrait::Re
duplicate_eliminated_columns.emplace_back(
make_uniq<PositionalReferenceExpression>(col.direct_reference().struct_field().field() + 1));
}

duplicate_eliminated_columns_ptr = &duplicate_eliminated_columns;
JoinType djointype;
switch (sjoin.type()) {
case substrait::DuplicateEliminatedJoinRel_JoinType::DuplicateEliminatedJoinRel_JoinType_JOIN_TYPE_INNER:
Expand All @@ -457,7 +457,7 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformDelimJoinOp(const substrait::Re
case substrait::DuplicateEliminatedJoinRel_JoinType::DuplicateEliminatedJoinRel_JoinType_JOIN_TYPE_RIGHT_SEMI:
djointype = JoinType::RIGHT_SEMI;
break;
case substrait::DuplicateEliminatedJoinRel_JoinType::DuplicateEliminatedJoinRel_JoinType_JOIN_TYPE_MARK:
case substrait::DuplicateEliminatedJoinRel_JoinType::DuplicateEliminatedJoinRel_JoinType_JOIN_TYPE_LEFT_MARK:
djointype = JoinType::MARK;
break;
case substrait::DuplicateEliminatedJoinRel_JoinType::DuplicateEliminatedJoinRel_JoinType_JOIN_TYPE_RIGHT_ANTI:
Expand Down Expand Up @@ -490,9 +490,11 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformDelimGetOp(const substrait::Rel
auto &client_context = con.context;
vector<LogicalType> chunk_types;
auto &input_columns = subtree->Columns();
for (auto &col_ref : delim_get.column_ids()) {
chunk_types.emplace_back(input_columns[col_ref.direct_reference().struct_field().field()].Type());
for (auto &col : *duplicate_eliminated_columns_ptr) {
auto& col_ref = col->Cast<PositionalReferenceExpression>();
chunk_types.emplace_back(input_columns[col_ref.index - 1].Type());
}
duplicate_eliminated_columns_ptr = nullptr;
return make_shared_ptr<DelimGetRelation>(client_context, chunk_types);
}

Expand Down
2 changes: 2 additions & 0 deletions src/include/from_substrait.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ class SubstraitToDuckDB {
//! names
static const unordered_map<std::string, std::string> function_names_remap;
static const case_insensitive_set_t valid_extract_subfields;
//! Pointer to last seen duplicate_eliminated_columns
vector<unique_ptr<ParsedExpression>> *duplicate_eliminated_columns_ptr = nullptr;
};
} // namespace duckdb
10 changes: 2 additions & 8 deletions src/to_substrait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ substrait::Rel *DuckDBToSubstrait::TransformComparisonJoin(LogicalOperator &dop)
sjoin->set_type(substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_LEFT_SEMI);
break;
case JoinType::MARK:
sjoin->set_type(substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_MARK);
sjoin->set_type(substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_LEFT_MARK);
break;
case JoinType::RIGHT_SEMI:
sjoin->set_type(substrait::JoinRel::JoinType::JoinRel_JoinType_JOIN_TYPE_RIGHT_SEMI);
Expand Down Expand Up @@ -1000,7 +1000,7 @@ substrait::Rel *DuckDBToSubstrait::TransformDelimiterJoin(LogicalOperator &dop)
break;
case JoinType::MARK:
sjoin->set_type(
substrait::DuplicateEliminatedJoinRel_JoinType::DuplicateEliminatedJoinRel_JoinType_JOIN_TYPE_MARK);
substrait::DuplicateEliminatedJoinRel_JoinType::DuplicateEliminatedJoinRel_JoinType_JOIN_TYPE_LEFT_MARK);
break;
case JoinType::RIGHT_ANTI:
sjoin->set_type(
Expand Down Expand Up @@ -1397,12 +1397,6 @@ substrait::Rel *DuckDBToSubstrait::TransformIntersect(LogicalOperator &dop) {
substrait::Rel *DuckDBToSubstrait::TransformDelimGet() {
auto rel = new substrait::Rel();
auto delim_get = rel->mutable_duplicate_eliminated_get();
D_ASSERT(duplicate_eliminated_parent_ptr);
for (auto &dup_col : duplicate_eliminated_parent_ptr->duplicate_eliminated_columns) {
auto &dref = dup_col->Cast<BoundReferenceExpression>();
auto s_dup_col = delim_get->add_column_ids();
s_dup_col->mutable_direct_reference()->mutable_struct_field()->set_field(static_cast<int32_t>(dref.index));
}
auto ref_input = delim_get->mutable_input();
ref_input->set_subtree_ordinal(cur_subtree_relation);
duplicate_eliminated_parent_ptr = nullptr;
Expand Down
Loading

0 comments on commit 73b072a

Please sign in to comment.