Skip to content

Commit

Permalink
vendor: Update vendored sources to duckdb/duckdb@6eb3eb6 (#837)
Browse files Browse the repository at this point in the history
Fix duckdb/duckdb#15072 and duckdb/duckdb#15073: propagate aliases correctly in * SIMILAR TO, and forbid `RENAME` as well (duckdb/duckdb#15247)
Linenoise: make Ctrl+G execute the query (duckdb/duckdb#15244)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and krlmlr authored Dec 29, 2024
1 parent cb5bdef commit e93a207
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 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 "4-dev3190"
#define DUCKDB_PATCH_VERSION "4-dev3194"
#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.4-dev3190"
#define DUCKDB_VERSION "v1.1.4-dev3194"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "bebfb9ddeb"
#define DUCKDB_SOURCE_ID "6eb3eb68b6"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
40 changes: 28 additions & 12 deletions src/duckdb/src/planner/binder/expression/bind_star_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ bool Binder::FindStarExpression(unique_ptr<ParsedExpression> &expr, StarExpressi
throw BinderException(
"STAR expression with REPLACE list is only allowed as the root element of COLUMNS");
}
if (!current_star.rename_list.empty()) {
// '*' inside COLUMNS can not have a REPLACE list
throw BinderException(
"STAR expression with RENAME list is only allowed as the root element of COLUMNS");
}

// '*' expression inside a COLUMNS - convert to a constant list of strings (column names)
vector<unique_ptr<ParsedExpression>> star_list;
Expand Down Expand Up @@ -162,26 +167,37 @@ void TryTransformStarLike(unique_ptr<ParsedExpression> &root) {
if (right->expression_class != ExpressionClass::CONSTANT) {
throw BinderException(*root, "Pattern applied to a star expression must be a constant");
}
if (!star.rename_list.empty()) {
throw BinderException(*root, "Rename list cannot be combined with a filtering operation");
}
if (!star.replace_list.empty()) {
throw BinderException(*root, "Replace list cannot be combined with a filtering operation");
}
// generate a columns expression
// "* LIKE '%literal%'
// -> COLUMNS(list_filter(*, x -> x LIKE '%literal%'))
auto original_alias = root->alias;
auto star_expr = std::move(left);
unique_ptr<ParsedExpression> child_expr;
if (function.function_name == "regexp_full_match" && star.exclude_list.empty()) {
// * SIMILAR TO '[regex]' is equivalent to COLUMNS('[regex]') so we can just move the expression directly
child_expr = std::move(right);
} else {
// for other expressions -> generate a columns expression
// "* LIKE '%literal%'
// -> COLUMNS(list_filter(*, x -> x LIKE '%literal%'))
auto lhs = make_uniq<ColumnRefExpression>("__lambda_col");
function.children[0] = lhs->Copy();

auto lhs = make_uniq<ColumnRefExpression>("__lambda_col");
function.children[0] = lhs->Copy();

auto lambda = make_uniq<LambdaExpression>(std::move(lhs), std::move(root));
vector<unique_ptr<ParsedExpression>> filter_children;
filter_children.push_back(std::move(star_expr));
filter_children.push_back(std::move(lambda));
auto list_filter = make_uniq<FunctionExpression>("list_filter", std::move(filter_children));
auto lambda = make_uniq<LambdaExpression>(std::move(lhs), std::move(root));
vector<unique_ptr<ParsedExpression>> filter_children;
filter_children.push_back(std::move(star_expr));
filter_children.push_back(std::move(lambda));
auto list_filter = make_uniq<FunctionExpression>("list_filter", std::move(filter_children));
child_expr = std::move(list_filter);
}

auto columns_expr = make_uniq<StarExpression>();
columns_expr->columns = true;
columns_expr->expr = std::move(list_filter);
columns_expr->expr = std::move(child_expr);
columns_expr->alias = std::move(original_alias);
root = std::move(columns_expr);
}

Expand Down

0 comments on commit e93a207

Please sign in to comment.