Skip to content

Commit

Permalink
chore: Update vendored sources to duckdb/duckdb@75d4bd0 (#420)
Browse files Browse the repository at this point in the history
Create a balanced union tree, also for export (duckdb/duckdb#13956)
[Dev] Add exclusion for `pybind11` internal `_pybind11_conduit_v1_` method (duckdb/duckdb#13961)
[Swift] Update README.md in Swift repo (duckdb/duckdb#13955)
CI: Trigger actions for labeled discussions (duckdb/duckdb#13937)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and krlmlr authored Sep 25, 2024
1 parent 08352d8 commit b1efaab
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/duckdb/src/function/table/version/pragma_version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DUCKDB_PATCH_VERSION
#define DUCKDB_PATCH_VERSION "1-dev124"
#define DUCKDB_PATCH_VERSION "1-dev132"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 1
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.1.1-dev124"
#define DUCKDB_VERSION "v1.1.1-dev132"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "c0f2946562"
#define DUCKDB_SOURCE_ID "75d4bd0cc7"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
2 changes: 2 additions & 0 deletions src/duckdb/src/include/duckdb/planner/binder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ class Binder : public enable_shared_from_this<Binder> {
unique_ptr<BoundTableRef> BindShowTable(ShowRef &ref);
unique_ptr<BoundTableRef> BindSummarize(ShowRef &ref);

unique_ptr<LogicalOperator> UnionOperators(vector<unique_ptr<LogicalOperator>> nodes);

private:
Binder(ClientContext &context, shared_ptr<Binder> parent, BinderType binder_type);
};
Expand Down
16 changes: 1 addition & 15 deletions src/duckdb/src/planner/binder/statement/bind_copy_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,7 @@ unique_ptr<LogicalOperator> Binder::BindCopyDatabaseData(Catalog &source_catalog
result->children.push_back(make_uniq<LogicalDummyScan>(GenerateTableIndex()));
} else {
// use UNION ALL to combine the individual copy statements into a single node
while (insert_nodes.size() > 1) {
vector<unique_ptr<LogicalOperator>> new_nodes;
for (idx_t i = 0; i < insert_nodes.size(); i += 2) {
if (i + 1 == insert_nodes.size()) {
new_nodes.push_back(std::move(insert_nodes[i]));
} else {
auto copy_union = make_uniq<LogicalSetOperation>(
GenerateTableIndex(), 1U, std::move(insert_nodes[i]), std::move(insert_nodes[i + 1]),
LogicalOperatorType::LOGICAL_UNION, true, false);
new_nodes.push_back(std::move(copy_union));
}
}
insert_nodes = std::move(new_nodes);
}
result = std::move(insert_nodes[0]);
result = UnionOperators(std::move(insert_nodes));
}
return result;
}
Expand Down
33 changes: 24 additions & 9 deletions src/duckdb/src/planner/binder/statement/bind_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@ static unique_ptr<QueryNode> CreateSelectStatement(CopyStatement &stmt, child_li
return std::move(statement);
}

unique_ptr<LogicalOperator> Binder::UnionOperators(vector<unique_ptr<LogicalOperator>> nodes) {
if (nodes.empty()) {
return nullptr;
}
while (nodes.size() > 1) {
vector<unique_ptr<LogicalOperator>> new_nodes;
for (idx_t i = 0; i < nodes.size(); i += 2) {
if (i + 1 == nodes.size()) {
new_nodes.push_back(std::move(nodes[i]));
} else {
auto copy_union = make_uniq<LogicalSetOperation>(GenerateTableIndex(), 1U, std::move(nodes[i]),
std::move(nodes[i + 1]),
LogicalOperatorType::LOGICAL_UNION, true, false);
new_nodes.push_back(std::move(copy_union));
}
}
nodes = std::move(new_nodes);
}
return std::move(nodes[0]);
}

BoundStatement Binder::Bind(ExportStatement &stmt) {
// COPY TO a file
auto &config = DBConfig::GetConfig(context);
Expand Down Expand Up @@ -170,11 +191,11 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {

// now generate the COPY statements for each of the tables
auto &fs = FileSystem::GetFileSystem(context);
unique_ptr<LogicalOperator> child_operator;

BoundExportData exported_tables;

unordered_set<string> table_name_index;
vector<unique_ptr<LogicalOperator>> export_nodes;
for (auto &t : tables) {
auto &table = t.get().Cast<TableCatalogEntry>();
auto info = make_uniq<CopyInfo>();
Expand Down Expand Up @@ -237,15 +258,9 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {

auto plan = std::move(bound_statement.plan);

if (child_operator) {
// use UNION ALL to combine the individual copy statements into a single node
auto copy_union = make_uniq<LogicalSetOperation>(GenerateTableIndex(), 1U, std::move(child_operator),
std::move(plan), LogicalOperatorType::LOGICAL_UNION, true);
child_operator = std::move(copy_union);
} else {
child_operator = std::move(plan);
}
export_nodes.push_back(std::move(plan));
}
auto child_operator = UnionOperators(std::move(export_nodes));

// try to create the directory, if it doesn't exist yet
// a bit hacky to do it here, but we need to create the directory BEFORE the copy statements run
Expand Down

0 comments on commit b1efaab

Please sign in to comment.