From 6e7b3819d09bd08a2cbbc20a627864e7a84a6c7c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:36:50 +0000 Subject: [PATCH] vendor: Update vendored sources to duckdb/duckdb@13ff921d7c4c5947dd69eaa6191c3cedad5672b8 (#937) Re-enable iceberg extension (duckdb/duckdb#15456) Co-authored-by: krlmlr --- .../function/table/version/pragma_version.cpp | 6 +- src/duckdb/src/main/relation.cpp.orig | 431 ------------------ 2 files changed, 3 insertions(+), 434 deletions(-) delete mode 100644 src/duckdb/src/main/relation.cpp.orig diff --git a/src/duckdb/src/function/table/version/pragma_version.cpp b/src/duckdb/src/function/table/version/pragma_version.cpp index 0faa986d7..202cadf3c 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 "4-dev3914" +#define DUCKDB_PATCH_VERSION "4-dev3916" #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.4-dev3914" +#define DUCKDB_VERSION "v1.1.4-dev3916" #endif #ifndef DUCKDB_SOURCE_ID -#define DUCKDB_SOURCE_ID "e1db888231" +#define DUCKDB_SOURCE_ID "13ff921d7c" #endif #include "duckdb/function/table/system_functions.hpp" #include "duckdb/main/database.hpp" diff --git a/src/duckdb/src/main/relation.cpp.orig b/src/duckdb/src/main/relation.cpp.orig deleted file mode 100644 index 9a28349e7..000000000 --- a/src/duckdb/src/main/relation.cpp.orig +++ /dev/null @@ -1,431 +0,0 @@ -#include "duckdb/main/relation.hpp" -#include "duckdb/common/printer.hpp" -#include "duckdb/parser/parser.hpp" -#include "duckdb/main/relation/aggregate_relation.hpp" -#include "duckdb/main/relation/cross_product_relation.hpp" -#include "duckdb/main/relation/distinct_relation.hpp" -#include "duckdb/main/relation/explain_relation.hpp" -#include "duckdb/main/relation/filter_relation.hpp" -#include "duckdb/main/relation/insert_relation.hpp" -#include "duckdb/main/relation/limit_relation.hpp" -#include "duckdb/main/relation/order_relation.hpp" -#include "duckdb/main/relation/projection_relation.hpp" -#include "duckdb/main/relation/setop_relation.hpp" -#include "duckdb/main/relation/subquery_relation.hpp" -#include "duckdb/main/relation/table_function_relation.hpp" -#include "duckdb/main/relation/create_table_relation.hpp" -#include "duckdb/main/relation/create_view_relation.hpp" -#include "duckdb/main/relation/write_csv_relation.hpp" -#include "duckdb/main/relation/write_parquet_relation.hpp" -#include "duckdb/main/client_context.hpp" -#include "duckdb/planner/binder.hpp" -#include "duckdb/parser/tableref/subqueryref.hpp" -#include "duckdb/parser/statement/select_statement.hpp" -#include "duckdb/parser/expression/conjunction_expression.hpp" -#include "duckdb/parser/expression/columnref_expression.hpp" -#include "duckdb/main/relation/join_relation.hpp" -#include "duckdb/main/relation/value_relation.hpp" -#include "duckdb/parser/statement/explain_statement.hpp" - -namespace duckdb { - -shared_ptr Relation::Project(const string &select_list) { - return Project(select_list, vector()); -} - -shared_ptr Relation::Project(const string &expression, const string &alias) { - return Project(expression, vector({alias})); -} - -shared_ptr Relation::Project(const string &select_list, const vector &aliases) { - auto expressions = Parser::ParseExpressionList(select_list, context->GetContext()->GetParserOptions()); - return make_shared_ptr(shared_from_this(), std::move(expressions), aliases); -} - -shared_ptr Relation::Project(const vector &expressions) { - vector aliases; - return Project(expressions, aliases); -} - -shared_ptr Relation::Project(vector> expressions, - const vector &aliases) { - return make_shared_ptr(shared_from_this(), std::move(expressions), aliases); -} - -static vector> StringListToExpressionList(const ClientContext &context, - const vector &expressions) { - if (expressions.empty()) { - throw ParserException("Zero expressions provided"); - } - vector> result_list; - for (auto &expr : expressions) { - auto expression_list = Parser::ParseExpressionList(expr, context.GetParserOptions()); - if (expression_list.size() != 1) { - throw ParserException("Expected a single expression in the expression list"); - } - result_list.push_back(std::move(expression_list[0])); - } - return result_list; -} - -shared_ptr Relation::Project(const vector &expressions, const vector &aliases) { - auto result_list = StringListToExpressionList(*context->GetContext(), expressions); - return make_shared_ptr(shared_from_this(), std::move(result_list), aliases); -} - -shared_ptr Relation::Filter(const string &expression) { - auto expression_list = Parser::ParseExpressionList(expression, context->GetContext()->GetParserOptions()); - if (expression_list.size() != 1) { - throw ParserException("Expected a single expression as filter condition"); - } - return Filter(std::move(expression_list[0])); -} - -shared_ptr Relation::Filter(unique_ptr expression) { - return make_shared_ptr(shared_from_this(), std::move(expression)); -} - -shared_ptr Relation::Filter(const vector &expressions) { - // if there are multiple expressions, we AND them together - auto expression_list = StringListToExpressionList(*context->GetContext(), expressions); - D_ASSERT(!expression_list.empty()); - - auto expr = std::move(expression_list[0]); - for (idx_t i = 1; i < expression_list.size(); i++) { - expr = make_uniq(ExpressionType::CONJUNCTION_AND, std::move(expr), - std::move(expression_list[i])); - } - return make_shared_ptr(shared_from_this(), std::move(expr)); -} - -shared_ptr Relation::Limit(int64_t limit, int64_t offset) { - return make_shared_ptr(shared_from_this(), limit, offset); -} - -shared_ptr Relation::Order(const string &expression) { - auto order_list = Parser::ParseOrderList(expression, context->GetContext()->GetParserOptions()); - return Order(std::move(order_list)); -} - -shared_ptr Relation::Order(vector order_list) { - return make_shared_ptr(shared_from_this(), std::move(order_list)); -} - -shared_ptr Relation::Order(const vector &expressions) { - if (expressions.empty()) { - throw ParserException("Zero ORDER BY expressions provided"); - } - vector order_list; - for (auto &expression : expressions) { - auto inner_list = Parser::ParseOrderList(expression, context->GetContext()->GetParserOptions()); - if (inner_list.size() != 1) { - throw ParserException("Expected a single ORDER BY expression in the expression list"); - } - order_list.push_back(std::move(inner_list[0])); - } - return Order(std::move(order_list)); -} - -shared_ptr Relation::Join(const shared_ptr &other, const string &condition, JoinType type, - JoinRefType ref_type) { - auto expression_list = Parser::ParseExpressionList(condition, context->GetContext()->GetParserOptions()); - D_ASSERT(!expression_list.empty()); - return Join(other, std::move(expression_list), type, ref_type); -} - -shared_ptr Relation::Join(const shared_ptr &other, - vector> expression_list, JoinType type, - JoinRefType ref_type) { - if (expression_list.size() > 1 || expression_list[0]->GetExpressionType() == ExpressionType::COLUMN_REF) { - // multiple columns or single column ref: the condition is a USING list - vector using_columns; - for (auto &expr : expression_list) { - if (expr->GetExpressionType() != ExpressionType::COLUMN_REF) { - throw ParserException("Expected a single expression as join condition"); - } - auto &colref = expr->Cast(); - if (colref.IsQualified()) { - throw ParserException("Expected unqualified column for column in USING clause"); - } - using_columns.push_back(colref.column_names[0]); - } - return make_shared_ptr(shared_from_this(), other, std::move(using_columns), type, ref_type); - } else { - // single expression that is not a column reference: use the expression as a join condition - return make_shared_ptr(shared_from_this(), other, std::move(expression_list[0]), type, ref_type); - } -} - -shared_ptr Relation::CrossProduct(const shared_ptr &other, JoinRefType join_ref_type) { - return make_shared_ptr(shared_from_this(), other, join_ref_type); -} - -shared_ptr Relation::Union(const shared_ptr &other) { - return make_shared_ptr(shared_from_this(), other, SetOperationType::UNION, true); -} - -shared_ptr Relation::Except(const shared_ptr &other) { - return make_shared_ptr(shared_from_this(), other, SetOperationType::EXCEPT, true); -} - -shared_ptr Relation::Intersect(const shared_ptr &other) { - return make_shared_ptr(shared_from_this(), other, SetOperationType::INTERSECT, true); -} - -shared_ptr Relation::Distinct() { - return make_shared_ptr(shared_from_this()); -} - -shared_ptr Relation::Alias(const string &alias) { - return make_shared_ptr(shared_from_this(), alias); -} - -shared_ptr Relation::Aggregate(const string &aggregate_list) { - auto expression_list = Parser::ParseExpressionList(aggregate_list, context->GetContext()->GetParserOptions()); - return make_shared_ptr(shared_from_this(), std::move(expression_list)); -} - -shared_ptr Relation::Aggregate(vector> expressions) { - return make_shared_ptr(shared_from_this(), std::move(expressions)); -} - -shared_ptr Relation::Aggregate(const string &aggregate_list, const string &group_list) { - auto expression_list = Parser::ParseExpressionList(aggregate_list, context->GetContext()->GetParserOptions()); - auto groups = Parser::ParseGroupByList(group_list, context->GetContext()->GetParserOptions()); - return make_shared_ptr(shared_from_this(), std::move(expression_list), std::move(groups)); -} - -shared_ptr Relation::Aggregate(const vector &aggregates) { - auto aggregate_list = StringListToExpressionList(*context->GetContext(), aggregates); - return make_shared_ptr(shared_from_this(), std::move(aggregate_list)); -} - -shared_ptr Relation::Aggregate(const vector &aggregates, const vector &groups) { - auto aggregate_list = StringUtil::Join(aggregates, ", "); - auto group_list = StringUtil::Join(groups, ", "); - return this->Aggregate(aggregate_list, group_list); -} - -shared_ptr Relation::Aggregate(vector> expressions, const string &group_list) { - auto groups = Parser::ParseGroupByList(group_list, context->GetContext()->GetParserOptions()); - return make_shared_ptr(shared_from_this(), std::move(expressions), std::move(groups)); -} - -string Relation::GetAlias() { - return alias; -} - -unique_ptr Relation::GetTableRef() { - auto select = make_uniq(); - select->node = GetQueryNode(); - return make_uniq(std::move(select), GetAlias()); -} - -unique_ptr Relation::Execute() { - return context->GetContext()->Execute(shared_from_this()); -} - -unique_ptr Relation::ExecuteOrThrow() { - auto res = Execute(); - D_ASSERT(res); - if (res->HasError()) { - res->ThrowError(); - } - return res; -} - -BoundStatement Relation::Bind(Binder &binder) { - SelectStatement stmt; - stmt.node = GetQueryNode(); - return binder.Bind(stmt.Cast()); -} - -shared_ptr Relation::InsertRel(const string &schema_name, const string &table_name) { - return make_shared_ptr(shared_from_this(), schema_name, table_name); -} - -void Relation::Insert(const string &table_name) { - Insert(INVALID_SCHEMA, table_name); -} - -void Relation::Insert(const string &schema_name, const string &table_name) { - auto insert = InsertRel(schema_name, table_name); - auto res = insert->Execute(); - if (res->HasError()) { - const string prepended_message = "Failed to insert into table '" + table_name + "': "; - res->ThrowError(prepended_message); - } -} - -void Relation::Insert(const vector> &values) { - vector column_names; - auto rel = make_shared_ptr(context->GetContext(), values, std::move(column_names), "values"); - rel->Insert(GetAlias()); -} - -void Relation::Insert(vector>> &&expressions) { - vector column_names; - auto rel = make_shared_ptr(context->GetContext(), std::move(expressions), std::move(column_names), - "values"); - rel->Insert(GetAlias()); -} - -shared_ptr Relation::CreateRel(const string &schema_name, const string &table_name, bool temporary, - OnCreateConflict on_conflict) { - return make_shared_ptr(shared_from_this(), schema_name, table_name, temporary, on_conflict); -} - -void Relation::Create(const string &table_name, bool temporary, OnCreateConflict on_conflict) { - Create(INVALID_SCHEMA, table_name, temporary, on_conflict); -} - -void Relation::Create(const string &schema_name, const string &table_name, bool temporary, - OnCreateConflict on_conflict) { - auto create = CreateRel(schema_name, table_name, temporary, on_conflict); - auto res = create->Execute(); - if (res->HasError()) { - const string prepended_message = "Failed to create table '" + table_name + "': "; - res->ThrowError(prepended_message); - } -} - -shared_ptr Relation::WriteCSVRel(const string &csv_file, case_insensitive_map_t> options) { - return make_shared_ptr(shared_from_this(), csv_file, std::move(options)); -} - -void Relation::WriteCSV(const string &csv_file, case_insensitive_map_t> options) { - auto write_csv = WriteCSVRel(csv_file, std::move(options)); - auto res = write_csv->Execute(); - if (res->HasError()) { - const string prepended_message = "Failed to write '" + csv_file + "': "; - res->ThrowError(prepended_message); - } -} - -shared_ptr Relation::WriteParquetRel(const string &parquet_file, - case_insensitive_map_t> options) { - auto write_parquet = - make_shared_ptr(shared_from_this(), parquet_file, std::move(options)); - return std::move(write_parquet); -} - -void Relation::WriteParquet(const string &parquet_file, case_insensitive_map_t> options) { - auto write_parquet = WriteParquetRel(parquet_file, std::move(options)); - auto res = write_parquet->Execute(); - if (res->HasError()) { - const string prepended_message = "Failed to write '" + parquet_file + "': "; - res->ThrowError(prepended_message); - } -} - -shared_ptr Relation::CreateView(const string &name, bool replace, bool temporary) { - return CreateView(INVALID_SCHEMA, name, replace, temporary); -} - -shared_ptr Relation::CreateView(const string &schema_name, const string &name, bool replace, bool temporary) { - auto view = make_shared_ptr(shared_from_this(), schema_name, name, replace, temporary); - auto res = view->Execute(); - if (res->HasError()) { - const string prepended_message = "Failed to create view '" + name + "': "; - res->ThrowError(prepended_message); - } - return shared_from_this(); -} - -unique_ptr Relation::Query(const string &sql) const { - return context->GetContext()->Query(sql, false); -} - -unique_ptr Relation::Query(const string &name, const string &sql) { - CreateView(name); - return Query(sql); -} - -unique_ptr Relation::Explain(ExplainType type, ExplainFormat format) { - auto explain = make_shared_ptr(shared_from_this(), type, format); - return explain->Execute(); -} - -void Relation::TryBindRelation(vector &columns) { - context->TryBindRelation(*this, columns); -} - -void Relation::Update(const string &update, const string &condition) { - throw InvalidInputException("UPDATE can only be used on base tables!"); -} - -void Relation::Update(vector, // NOLINT: unused variable / copied on every invocation ... - vector> &&update, // NOLINT: unused variable - unique_ptr condition) { // NOLINT: unused variable - (void)std::move(update); - (void)std::move(condition); - throw InvalidInputException("UPDATE can only be used on base tables!"); -} - -void Relation::Delete(const string &condition) { - throw InvalidInputException("DELETE can only be used on base tables!"); -} - -shared_ptr Relation::TableFunction(const std::string &fname, const vector &values, - const named_parameter_map_t &named_parameters) { - return make_shared_ptr(context->GetContext(), fname, values, named_parameters, - shared_from_this()); -} - -shared_ptr Relation::TableFunction(const std::string &fname, const vector &values) { - return make_shared_ptr(context->GetContext(), fname, values, shared_from_this()); -} - -string Relation::ToString() { - string str; - str += "---------------------\n"; - str += "--- Relation Tree ---\n"; - str += "---------------------\n"; - str += ToString(0); - str += "\n\n"; - str += "---------------------\n"; - str += "-- Result Columns --\n"; - str += "---------------------\n"; - auto &cols = Columns(); - for (idx_t i = 0; i < cols.size(); i++) { - str += "- " + cols[i].Name() + " (" + cols[i].Type().ToString() + ")\n"; - } - return str; -} - -// LCOV_EXCL_START -unique_ptr Relation::GetQueryNode() { - throw InternalException("Cannot create a query node from this node type"); -} - -void Relation::Head(idx_t limit) { - auto limit_node = Limit(NumericCast(limit)); - limit_node->Execute()->Print(); -} -// LCOV_EXCL_STOP - -void Relation::Print() { - Printer::Print(ToString()); -} - -string Relation::RenderWhitespace(idx_t depth) { - return string(depth * 2, ' '); -} - -void Relation::AddExternalDependency(shared_ptr dependency) { - external_dependencies.push_back(std::move(dependency)); -} - -vector> Relation::GetAllDependencies() { - vector> all_dependencies; - Relation *cur = this; - while (cur) { - for (auto &dep : cur->external_dependencies) { - all_dependencies.push_back(dep); - } - cur = cur->ChildRelation(); - } - return all_dependencies; -} - -} // namespace duckdb