Skip to content

Commit

Permalink
chore: Update vendored sources to duckdb/duckdb@04a1f75 (#431)
Browse files Browse the repository at this point in the history
[Fix] Throw exception for UNNEST in lambdas (duckdb/duckdb#13969)
Fix partitions on wide tables (duckdb/duckdb#13988)

Co-authored-by: krlmlr <[email protected]>
  • Loading branch information
github-actions[bot] and krlmlr authored Sep 27, 2024
1 parent 0480949 commit c12b67a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 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-dev183"
#define DUCKDB_PATCH_VERSION "1-dev190"
#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-dev183"
#define DUCKDB_VERSION "v1.1.1-dev190"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "0da70d9de9"
#define DUCKDB_SOURCE_ID "04a1f750a6"
#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/expression_binder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "duckdb/catalog/catalog_entry_retriever.hpp"
#include "duckdb/planner/expression/bound_lambda_expression.hpp"
#include "duckdb/function/scalar_function.hpp"
#include "duckdb/planner/column_binding.hpp"

namespace duckdb {

Expand Down Expand Up @@ -219,6 +220,7 @@ class ExpressionBinder {
//! Returns true if the function name is an alias for the UNNEST function
static bool IsUnnestFunction(const string &function_name);
BindResult TryBindLambdaOrJson(FunctionExpression &function, idx_t depth, CatalogEntry &func);
virtual void ThrowIfUnnestInLambda(const ColumnBinding &column_binding);
};

} // namespace duckdb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SelectBinder : public BaseSelectBinder {
SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info);

protected:
void ThrowIfUnnestInLambda(const ColumnBinding &column_binding) override;
BindResult BindUnnest(FunctionExpression &function, idx_t depth, bool root_expression) override;
BindResult BindColumnRef(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth, bool root_expression) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ BindResult ExpressionBinder::BindUnnest(FunctionExpression &expr, idx_t depth, b
return BindUnsupportedExpression(expr, depth, UnsupportedUnnestMessage());
}

void ExpressionBinder::ThrowIfUnnestInLambda(const ColumnBinding &column_binding) {
}

string ExpressionBinder::UnsupportedAggregateMessage() {
return "Aggregate functions are not supported here";
}
Expand Down
8 changes: 7 additions & 1 deletion src/duckdb/src/planner/binder/expression/bind_lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void ExpressionBinder::CaptureLambdaColumns(BoundLambdaExpression &bound_lambda_
const LogicalType &list_child_type) {

if (expr->expression_class == ExpressionClass::BOUND_SUBQUERY) {
throw InvalidInputException("Subqueries are not supported in lambda expressions!");
throw BinderException("subqueries in lambda expressions are not supported");
}

// these are bound depth-first
Expand All @@ -195,6 +195,12 @@ void ExpressionBinder::CaptureLambdaColumns(BoundLambdaExpression &bound_lambda_
expr->expression_class == ExpressionClass::BOUND_PARAMETER ||
expr->expression_class == ExpressionClass::BOUND_LAMBDA_REF) {

if (expr->expression_class == ExpressionClass::BOUND_COLUMN_REF) {
// Search for UNNEST.
auto &column_binding = expr->Cast<BoundColumnRefExpression>().binding;
ThrowIfUnnestInLambda(column_binding);
}

// move the expr because we are going to replace it
auto original = std::move(expr);
unique_ptr<Expression> replacement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ unique_ptr<Expression> CreateBoundStructExtractIndex(ClientContext &context, uni
return std::move(result);
}

void SelectBinder::ThrowIfUnnestInLambda(const ColumnBinding &column_binding) {
// Extract the unnests and check if any match the column index.
for (auto &node_pair : node.unnests) {
auto &unnest_node = node_pair.second;

if (unnest_node.index == column_binding.table_index) {
if (column_binding.column_index < unnest_node.expressions.size()) {
throw BinderException("UNNEST in lambda expressions is not supported");
}
}
}
}

BindResult SelectBinder::BindUnnest(FunctionExpression &function, idx_t depth, bool root_expression) {
// bind the children of the function expression
if (depth > 0) {
Expand Down

0 comments on commit c12b67a

Please sign in to comment.