-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update vendored DuckDB sources to 941d1e6
- Loading branch information
1 parent
941d1e6
commit 8934827
Showing
14 changed files
with
176 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
|
||
#include "duckdb/execution/operator/order/physical_order.hpp" | ||
#include "duckdb/execution/operator/projection/physical_projection.hpp" | ||
#include "duckdb/execution/operator/filter/physical_filter.hpp" | ||
#include "duckdb/execution/operator/schema/physical_create_art_index.hpp" | ||
|
||
#include "duckdb/planner/expression/bound_operator_expression.hpp" | ||
#include "duckdb/planner/expression/bound_reference_expression.hpp" | ||
#include "duckdb/planner/operator/logical_create_index.hpp" | ||
|
||
#include "duckdb/execution/index/art/art.hpp" | ||
|
||
namespace duckdb { | ||
|
||
unique_ptr<PhysicalOperator> ART::CreatePlan(PlanIndexInput &input) { | ||
// generate a physical plan for the parallel index creation which consists of the following operators | ||
// table scan - projection (for expression execution) - filter (NOT NULL) - order (if applicable) - create index | ||
|
||
auto &op = input.op; | ||
auto &table_scan = input.table_scan; | ||
|
||
vector<LogicalType> new_column_types; | ||
vector<unique_ptr<Expression>> select_list; | ||
for (idx_t i = 0; i < op.expressions.size(); i++) { | ||
new_column_types.push_back(op.expressions[i]->return_type); | ||
select_list.push_back(std::move(op.expressions[i])); | ||
} | ||
new_column_types.emplace_back(LogicalType::ROW_TYPE); | ||
select_list.push_back(make_uniq<BoundReferenceExpression>(LogicalType::ROW_TYPE, op.info->scan_types.size() - 1)); | ||
|
||
auto projection = make_uniq<PhysicalProjection>(new_column_types, std::move(select_list), op.estimated_cardinality); | ||
projection->children.push_back(std::move(table_scan)); | ||
|
||
// filter operator for IS_NOT_NULL on each key column | ||
|
||
vector<LogicalType> filter_types; | ||
vector<unique_ptr<Expression>> filter_select_list; | ||
|
||
for (idx_t i = 0; i < new_column_types.size() - 1; i++) { | ||
filter_types.push_back(new_column_types[i]); | ||
auto is_not_null_expr = | ||
make_uniq<BoundOperatorExpression>(ExpressionType::OPERATOR_IS_NOT_NULL, LogicalType::BOOLEAN); | ||
auto bound_ref = make_uniq<BoundReferenceExpression>(new_column_types[i], i); | ||
is_not_null_expr->children.push_back(std::move(bound_ref)); | ||
filter_select_list.push_back(std::move(is_not_null_expr)); | ||
} | ||
|
||
auto null_filter = | ||
make_uniq<PhysicalFilter>(std::move(filter_types), std::move(filter_select_list), op.estimated_cardinality); | ||
null_filter->types.emplace_back(LogicalType::ROW_TYPE); | ||
null_filter->children.push_back(std::move(projection)); | ||
|
||
// determine if we sort the data prior to index creation | ||
// we don't sort, if either VARCHAR or compound key | ||
auto perform_sorting = true; | ||
if (op.unbound_expressions.size() > 1) { | ||
perform_sorting = false; | ||
} else if (op.unbound_expressions[0]->return_type.InternalType() == PhysicalType::VARCHAR) { | ||
perform_sorting = false; | ||
} | ||
|
||
// actual physical create index operator | ||
|
||
auto physical_create_index = | ||
make_uniq<PhysicalCreateARTIndex>(op, op.table, op.info->column_ids, std::move(op.info), | ||
std::move(op.unbound_expressions), op.estimated_cardinality, perform_sorting); | ||
|
||
if (perform_sorting) { | ||
|
||
// optional order operator | ||
vector<BoundOrderByNode> orders; | ||
vector<idx_t> projections; | ||
for (idx_t i = 0; i < new_column_types.size() - 1; i++) { | ||
auto col_expr = make_uniq_base<Expression, BoundReferenceExpression>(new_column_types[i], i); | ||
orders.emplace_back(OrderType::ASCENDING, OrderByNullType::NULLS_FIRST, std::move(col_expr)); | ||
projections.emplace_back(i); | ||
} | ||
projections.emplace_back(new_column_types.size() - 1); | ||
|
||
auto physical_order = make_uniq<PhysicalOrder>(new_column_types, std::move(orders), std::move(projections), | ||
op.estimated_cardinality); | ||
physical_order->children.push_back(std::move(null_filter)); | ||
|
||
physical_create_index->children.push_back(std::move(physical_order)); | ||
} else { | ||
|
||
// no ordering | ||
physical_create_index->children.push_back(std::move(null_filter)); | ||
} | ||
|
||
return std::move(physical_create_index); | ||
} | ||
|
||
} // namespace duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.