From b1efaab7de3822e4411031f73bdb2eaf60a1d5de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:37:58 +0000 Subject: [PATCH] chore: Update vendored sources to duckdb/duckdb@75d4bd0cc759dcb609ab349b87bff07dddf2ebb7 (#420) 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 --- .../function/table/version/pragma_version.cpp | 6 ++-- .../src/include/duckdb/planner/binder.hpp | 2 ++ .../binder/statement/bind_copy_database.cpp | 16 +-------- .../planner/binder/statement/bind_export.cpp | 33 ++++++++++++++----- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/duckdb/src/function/table/version/pragma_version.cpp b/src/duckdb/src/function/table/version/pragma_version.cpp index aabdeef76..7a4e82653 100644 --- a/src/duckdb/src/function/table/version/pragma_version.cpp +++ b/src/duckdb/src/function/table/version/pragma_version.cpp @@ -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 @@ -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" diff --git a/src/duckdb/src/include/duckdb/planner/binder.hpp b/src/duckdb/src/include/duckdb/planner/binder.hpp index 8c2760a4b..cdfc67d1b 100644 --- a/src/duckdb/src/include/duckdb/planner/binder.hpp +++ b/src/duckdb/src/include/duckdb/planner/binder.hpp @@ -416,6 +416,8 @@ class Binder : public enable_shared_from_this { unique_ptr BindShowTable(ShowRef &ref); unique_ptr BindSummarize(ShowRef &ref); + unique_ptr UnionOperators(vector> nodes); + private: Binder(ClientContext &context, shared_ptr parent, BinderType binder_type); }; diff --git a/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp b/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp index 0c53ea78e..f05445e90 100644 --- a/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp +++ b/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp @@ -96,21 +96,7 @@ unique_ptr Binder::BindCopyDatabaseData(Catalog &source_catalog result->children.push_back(make_uniq(GenerateTableIndex())); } else { // use UNION ALL to combine the individual copy statements into a single node - while (insert_nodes.size() > 1) { - vector> 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( - 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; } diff --git a/src/duckdb/src/planner/binder/statement/bind_export.cpp b/src/duckdb/src/planner/binder/statement/bind_export.cpp index 19abaf3a8..a183738ad 100644 --- a/src/duckdb/src/planner/binder/statement/bind_export.cpp +++ b/src/duckdb/src/planner/binder/statement/bind_export.cpp @@ -136,6 +136,27 @@ static unique_ptr CreateSelectStatement(CopyStatement &stmt, child_li return std::move(statement); } +unique_ptr Binder::UnionOperators(vector> nodes) { + if (nodes.empty()) { + return nullptr; + } + while (nodes.size() > 1) { + vector> 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(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); @@ -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 child_operator; BoundExportData exported_tables; unordered_set table_name_index; + vector> export_nodes; for (auto &t : tables) { auto &table = t.get().Cast(); auto info = make_uniq(); @@ -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(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