Skip to content

Commit

Permalink
Revert "Improve EXPLAIN output of Delim Joins and Delim Gets"
Browse files Browse the repository at this point in the history
This reverts commit 23ccd79.
  • Loading branch information
kryonix committed Jul 17, 2024
1 parent afa75f6 commit a14b34e
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/execution/physical_plan/plan_delim_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalDelimGet &
// create a PhysicalChunkScan without an owned_collection, the collection will be added later
auto chunk_scan = make_uniq<PhysicalColumnDataScan>(op.types, PhysicalOperatorType::DELIM_SCAN,
op.estimated_cardinality, nullptr);
chunk_scan->delim_index = op.delim_idx;
return std::move(chunk_scan);
}

Expand Down
8 changes: 3 additions & 5 deletions src/execution/physical_plan/plan_delim_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::PlanDelimJoin(LogicalCompari
// now create the duplicate eliminated join
unique_ptr<PhysicalDelimJoin> delim_join;
if (op.delim_flipped) {
delim_join = make_uniq<PhysicalRightDelimJoin>(op.types, std::move(plan), delim_scans, op.estimated_cardinality,
op.mark_index);
delim_join =
make_uniq<PhysicalRightDelimJoin>(op.types, std::move(plan), delim_scans, op.estimated_cardinality, optional_idx(++this->delim_index));
} else {
delim_join = make_uniq<PhysicalLeftDelimJoin>(op.types, std::move(plan), delim_scans, op.estimated_cardinality,
op.mark_index);
delim_join = make_uniq<PhysicalLeftDelimJoin>(op.types, std::move(plan), delim_scans, op.estimated_cardinality, optional_idx(++this->delim_index));
}
// we still have to create the DISTINCT clause that is used to generate the duplicate eliminated chunk
delim_join->distinct = make_uniq<PhysicalHashAggregate>(context, delim_types, std::move(distinct_expressions),
std::move(distinct_groups), op.estimated_cardinality);

return std::move(delim_join);
}

Expand Down
2 changes: 2 additions & 0 deletions src/include/duckdb/execution/physical_plan_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class PhysicalPlanGenerator {
bool PreserveInsertionOrder(PhysicalOperator &plan);
bool UseBatchIndex(PhysicalOperator &plan);

idx_t delim_index = 0;

private:
ClientContext &context;
};
Expand Down
2 changes: 0 additions & 2 deletions src/include/duckdb/planner/operator/logical_delim_get.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class LogicalDelimGet : public LogicalOperator {
idx_t table_index;
//! The types of the chunk
vector<LogicalType> chunk_types;
//! Delim Join Index
optional_idx delim_idx;

public:
vector<ColumnBinding> GetColumnBindings() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ struct FlattenDependentJoins {
bool perform_delim;
bool any_join;

idx_t delim_root_idx;

private:
unique_ptr<LogicalOperator> PushDownDependentJoinInternal(unique_ptr<LogicalOperator> plan,
bool &parent_propagate_null_values, idx_t lateral_depth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,6 @@
"id": 201,
"name": "chunk_types",
"type": "vector<LogicalType>"
},
{
"id": 202,
"name": "delim_idx",
"type": "optional_idx",
"default": "optional_idx()"
}
],
"constructor": ["table_index", "chunk_types"]
Expand Down
8 changes: 0 additions & 8 deletions src/planner/binder/query_node/plan_subquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,14 @@ static unique_ptr<Expression> PlanCorrelatedSubquery(Binder &binder, BoundSubque
// the input value NULL will generate the value 42, and we need to join NULL on the LHS with NULL on the RHS
// the left side is the original plan
// this is the side that will be duplicate eliminated and pushed into the RHS
idx_t mark_index = binder.GenerateTableIndex();
auto delim_join =
CreateDuplicateEliminatedJoin(correlated_columns, JoinType::SINGLE, std::move(root), perform_delim);

delim_join->mark_index = mark_index;
// the right side initially is a DEPENDENT join between the duplicate eliminated scan and the subquery
// HOWEVER: we do not explicitly create the dependent join
// instead, we eliminate the dependent join by pushing it down into the right side of the plan
FlattenDependentJoins flatten(binder, correlated_columns, perform_delim);

flatten.delim_root_idx = mark_index;
// first we check which logical operators have correlated expressions in the first place
flatten.DetectCorrelatedExpressions(*plan);
// now we push the dependent join down
Expand All @@ -280,7 +277,6 @@ static unique_ptr<Expression> PlanCorrelatedSubquery(Binder &binder, BoundSubque
delim_join->mark_index = mark_index;
// RHS
FlattenDependentJoins flatten(binder, correlated_columns, perform_delim, true);
flatten.delim_root_idx = mark_index;
flatten.DetectCorrelatedExpressions(*plan);
auto dependent_join = flatten.PushDownDependentJoin(std::move(plan));

Expand Down Expand Up @@ -309,7 +305,6 @@ static unique_ptr<Expression> PlanCorrelatedSubquery(Binder &binder, BoundSubque
delim_join->mark_index = mark_index;
// RHS
FlattenDependentJoins flatten(binder, correlated_columns, true, true);
flatten.delim_root_idx = mark_index;
flatten.DetectCorrelatedExpressions(*plan);
auto dependent_join = flatten.PushDownDependentJoin(std::move(plan));

Expand Down Expand Up @@ -427,12 +422,9 @@ unique_ptr<LogicalOperator> Binder::PlanLateralJoin(unique_ptr<LogicalOperator>
}

auto perform_delim = PerformDuplicateElimination(*this, correlated);
idx_t delim_idx = GenerateTableIndex();
auto delim_join = CreateDuplicateEliminatedJoin(correlated, join_type, std::move(left), perform_delim);
delim_join->mark_index = delim_idx;

FlattenDependentJoins flatten(*this, correlated, perform_delim);
flatten.delim_root_idx = delim_idx;

// first we check which logical operators have correlated expressions in the first place
flatten.DetectCorrelatedExpressions(*right, true);
Expand Down
2 changes: 0 additions & 2 deletions src/planner/subquery/flatten_dependent_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
delim_offset = left_columns;
data_offset = 0;
delim_scan = make_uniq<LogicalDelimGet>(delim_index, delim_types);
delim_scan->delim_idx = optional_idx(delim_root_idx);
if (plan->type == LogicalOperatorType::LOGICAL_PROJECTION) {
// we want to keep the logical projection for positionality.
exit_projection = true;
Expand Down Expand Up @@ -270,7 +269,6 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
}
auto left_index = binder.GenerateTableIndex();
delim_scan = make_uniq<LogicalDelimGet>(left_index, delim_types);
delim_scan->delim_idx = optional_idx(delim_root_idx);
join->children.push_back(std::move(delim_scan));
join->children.push_back(std::move(plan));
for (idx_t i = 0; i < new_group_count; i++) {
Expand Down
2 changes: 0 additions & 2 deletions src/storage/serialization/serialize_logical_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,12 @@ void LogicalDelimGet::Serialize(Serializer &serializer) const {
LogicalOperator::Serialize(serializer);
serializer.WritePropertyWithDefault<idx_t>(200, "table_index", table_index);
serializer.WritePropertyWithDefault<vector<LogicalType>>(201, "chunk_types", chunk_types);
serializer.WritePropertyWithDefault<optional_idx>(202, "delim_idx", delim_idx, optional_idx());
}

unique_ptr<LogicalOperator> LogicalDelimGet::Deserialize(Deserializer &deserializer) {
auto table_index = deserializer.ReadPropertyWithDefault<idx_t>(200, "table_index");
auto chunk_types = deserializer.ReadPropertyWithDefault<vector<LogicalType>>(201, "chunk_types");
auto result = duckdb::unique_ptr<LogicalDelimGet>(new LogicalDelimGet(table_index, std::move(chunk_types)));
deserializer.ReadPropertyWithDefault<optional_idx>(202, "delim_idx", result->delim_idx, optional_idx());
return std::move(result);
}

Expand Down

0 comments on commit a14b34e

Please sign in to comment.