diff --git a/src/duckdb/src/execution/expression_executor/execute_comparison.cpp b/src/duckdb/src/execution/expression_executor/execute_comparison.cpp index 6e78de49c..f8fb8dc68 100644 --- a/src/duckdb/src/execution/expression_executor/execute_comparison.cpp +++ b/src/duckdb/src/execution/expression_executor/execute_comparison.cpp @@ -138,8 +138,19 @@ static idx_t TemplatedSelectOperation(Vector &left, Vector &right, optional_ptr< false_sel.get()); case PhysicalType::LIST: case PhysicalType::STRUCT: - case PhysicalType::ARRAY: - return NestedSelectOperation(left, right, sel, count, true_sel, false_sel, null_mask); + case PhysicalType::ARRAY: { + auto result_count = NestedSelectOperation(left, right, sel, count, true_sel, false_sel, null_mask); + if (true_sel && result_count > 0) { + std::sort(true_sel->data(), true_sel->data() + result_count); + } + if (false_sel) { + idx_t false_count = count - result_count; + if (false_count > 0) { + std::sort(false_sel->data(), false_sel->data() + false_count); + } + } + return result_count; + } default: throw InternalException("Invalid type for comparison"); } diff --git a/src/duckdb/src/function/table/version/pragma_version.cpp b/src/duckdb/src/function/table/version/pragma_version.cpp index e8661848b..1a5fb1fc6 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 "2-dev291" +#define DUCKDB_PATCH_VERSION "2-dev305" #endif #ifndef DUCKDB_MINOR_VERSION #define DUCKDB_MINOR_VERSION 4 @@ -8,10 +8,10 @@ #define DUCKDB_MAJOR_VERSION 1 #endif #ifndef DUCKDB_VERSION -#define DUCKDB_VERSION "v1.4.2-dev291" +#define DUCKDB_VERSION "v1.4.2-dev305" #endif #ifndef DUCKDB_SOURCE_ID -#define DUCKDB_SOURCE_ID "396c86228b" +#define DUCKDB_SOURCE_ID "8090b8d52e" #endif #include "duckdb/function/table/system_functions.hpp" #include "duckdb/main/database.hpp" diff --git a/src/duckdb/src/include/duckdb/main/extension_entries.hpp b/src/duckdb/src/include/duckdb/main/extension_entries.hpp index 0d7d151df..5ab7e72d0 100644 --- a/src/duckdb/src/include/duckdb/main/extension_entries.hpp +++ b/src/duckdb/src/include/duckdb/main/extension_entries.hpp @@ -227,6 +227,7 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = { {"iceberg_metadata", "iceberg", CatalogType::TABLE_FUNCTION_ENTRY}, {"iceberg_scan", "iceberg", CatalogType::TABLE_FUNCTION_ENTRY}, {"iceberg_snapshots", "iceberg", CatalogType::TABLE_FUNCTION_ENTRY}, + {"iceberg_table_properties", "iceberg", CatalogType::TABLE_FUNCTION_ENTRY}, {"iceberg_to_ducklake", "iceberg", CatalogType::TABLE_FUNCTION_ENTRY}, {"icu_calendar_names", "icu", CatalogType::TABLE_FUNCTION_ENTRY}, {"icu_collate_af", "icu", CatalogType::SCALAR_FUNCTION_ENTRY}, @@ -525,6 +526,7 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = { {"regr_sxx", "core_functions", CatalogType::AGGREGATE_FUNCTION_ENTRY}, {"regr_sxy", "core_functions", CatalogType::AGGREGATE_FUNCTION_ENTRY}, {"regr_syy", "core_functions", CatalogType::AGGREGATE_FUNCTION_ENTRY}, + {"remove_iceberg_table_properties", "iceberg", CatalogType::TABLE_FUNCTION_ENTRY}, {"repeat", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY}, {"replace", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY}, {"replace_type", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY}, @@ -540,6 +542,7 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = { {"rtrim", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY}, {"sem", "core_functions", CatalogType::AGGREGATE_FUNCTION_ENTRY}, {"set_bit", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY}, + {"set_iceberg_table_properties", "iceberg", CatalogType::TABLE_FUNCTION_ENTRY}, {"setseed", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY}, {"shapefile_meta", "spatial", CatalogType::TABLE_FUNCTION_ENTRY}, {"sign", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY}, diff --git a/src/duckdb/src/planner/binder/statement/bind_merge_into.cpp b/src/duckdb/src/planner/binder/statement/bind_merge_into.cpp index 16cb6feb1..436f7d3e5 100644 --- a/src/duckdb/src/planner/binder/statement/bind_merge_into.cpp +++ b/src/duckdb/src/planner/binder/statement/bind_merge_into.cpp @@ -41,10 +41,20 @@ unique_ptr Binder::BindMergeAction(LogicalMergeInto &merge auto result = make_uniq(); result->action_type = action.action_type; if (action.condition) { - ProjectionBinder proj_binder(*this, context, proj_index, expressions, "WHERE clause"); - proj_binder.target_type = LogicalType::BOOLEAN; - auto cond = proj_binder.Bind(action.condition); - result->condition = std::move(cond); + if (action.condition->HasSubquery()) { + // if we have a subquery we need to execute the condition outside of the MERGE INTO statement + WhereBinder where_binder(*this, context); + auto cond = where_binder.Bind(action.condition); + PlanSubqueries(cond, root); + result->condition = + make_uniq(cond->return_type, ColumnBinding(proj_index, expressions.size())); + expressions.push_back(std::move(cond)); + } else { + ProjectionBinder proj_binder(*this, context, proj_index, expressions, "WHERE clause"); + proj_binder.target_type = LogicalType::BOOLEAN; + auto cond = proj_binder.Bind(action.condition); + result->condition = std::move(cond); + } } switch (action.action_type) { case MergeActionType::MERGE_UPDATE: { diff --git a/src/duckdb/src/storage/table/column_data.cpp b/src/duckdb/src/storage/table/column_data.cpp index 7ba1112e5..aafcf58a0 100644 --- a/src/duckdb/src/storage/table/column_data.cpp +++ b/src/duckdb/src/storage/table/column_data.cpp @@ -868,7 +868,8 @@ bool PersistentCollectionData::HasUpdates() const { } PersistentColumnData ColumnData::Serialize() { - PersistentColumnData result(type.InternalType(), GetDataPointers()); + auto result = count ? PersistentColumnData(type.InternalType(), GetDataPointers()) + : PersistentColumnData(type.InternalType()); result.has_updates = HasUpdates(); return result; }