Skip to content

Commit

Permalink
Update vendored DuckDB sources to 2e8ebca
Browse files Browse the repository at this point in the history
  • Loading branch information
duckdblabs-bot committed Dec 18, 2024
1 parent 2e8ebca commit 25c7873
Show file tree
Hide file tree
Showing 197 changed files with 707 additions and 617 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace duckdb {

static void AliasFunction(DataChunk &args, ExpressionState &state, Vector &result) {
auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
Value v(state.expr.alias.empty() ? func_expr.children[0]->GetName() : state.expr.alias);
Value v(state.expr.GetAlias().empty() ? func_expr.children[0]->GetName() : state.expr.GetAlias());
result.Reference(v);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ unique_ptr<FunctionData> BindLeastGreatest(ClientContext &context, ScalarFunctio
for (idx_t i = 1; i < arguments.size(); i++) {
auto arg_type = ExpressionBinder::GetExpressionReturnType(*arguments[i]);
if (!LogicalType::TryGetMaxLogicalType(context, child_type, arg_type, child_type)) {
throw BinderException(arguments[i]->query_location,
throw BinderException(arguments[i]->GetQueryLocation(),
"Cannot combine types of %s and %s - an explicit cast is required",
child_type.ToString(), arg_type.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static unique_ptr<FunctionData> ListFilterBind(ClientContext &context, ScalarFun

// the list column and the bound lambda expression
D_ASSERT(arguments.size() == 2);
if (arguments[1]->expression_class != ExpressionClass::BOUND_LAMBDA) {
if (arguments[1]->GetExpressionClass() != ExpressionClass::BOUND_LAMBDA) {
throw BinderException("Invalid lambda expression!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static unique_ptr<FunctionData> ListReduceBind(ClientContext &context, ScalarFun

// the list column and the bound lambda expression
D_ASSERT(arguments.size() == 2);
if (arguments[1]->expression_class != ExpressionClass::BOUND_LAMBDA) {
if (arguments[1]->GetExpressionClass() != ExpressionClass::BOUND_LAMBDA) {
throw BinderException("Invalid lambda expression!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static unique_ptr<FunctionData> ListTransformBind(ClientContext &context, Scalar

// the list column and the bound lambda expression
D_ASSERT(arguments.size() == 2);
if (arguments[1]->expression_class != ExpressionClass::BOUND_LAMBDA) {
if (arguments[1]->GetExpressionClass() != ExpressionClass::BOUND_LAMBDA) {
throw BinderException("Invalid lambda expression!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ static unique_ptr<FunctionData> ListValueBind(ClientContext &context, ScalarFunc
auto error =
StringUtil::Format("Cannot unpivot columns of types %s and %s - an explicit cast is required",
child_type.ToString(), arg_type.ToString());
throw BinderException(arguments[i]->query_location,
throw BinderException(arguments[i]->GetQueryLocation(),
QueryErrorContext::Format(list_arguments, error, error_index, false));
} else {
throw BinderException(arguments[i]->query_location,
throw BinderException(arguments[i]->GetQueryLocation(),
"Cannot create a list of types %s and %s - an explicit cast is required",
child_type.ToString(), arg_type.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ static unique_ptr<FunctionData> StructInsertBind(ClientContext &context, ScalarF
// Loop through the additional arguments (name/value pairs)
for (idx_t i = 1; i < arguments.size(); i++) {
auto &child = arguments[i];
if (child->alias.empty()) {
if (child->GetAlias().empty()) {
throw BinderException("Need named argument for struct insert, e.g., a := b");
}
if (name_collision_set.find(child->alias) != name_collision_set.end()) {
throw BinderException("Duplicate struct entry name \"%s\"", child->alias);
if (name_collision_set.find(child->GetAlias()) != name_collision_set.end()) {
throw BinderException("Duplicate struct entry name \"%s\"", child->GetAlias());
}
name_collision_set.insert(child->alias);
new_children.push_back(make_pair(child->alias, arguments[i]->return_type));
name_collision_set.insert(child->GetAlias());
new_children.push_back(make_pair(child->GetAlias(), arguments[i]->return_type));
}

bound_function.return_type = LogicalType::STRUCT(new_children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ static unique_ptr<FunctionData> UnionValueBind(ClientContext &context, ScalarFun
}
auto &child = arguments[0];

if (child->alias.empty()) {
if (child->GetAlias().empty()) {
throw BinderException("Need named argument for union tag, e.g. UNION_VALUE(a := b)");
}

child_list_t<LogicalType> union_members;

union_members.push_back(make_pair(child->alias, child->return_type));
union_members.push_back(make_pair(child->GetAlias(), child->return_type));

bound_function.return_type = LogicalType::UNION(std::move(union_members));
return make_uniq<VariableReturnBindData>(bound_function.return_type);
Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/extension/json/json_functions/copy_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static BoundStatement CopyToJSONPlan(Binder &binder, CopyStatement &stmt) {
strftime_children.emplace_back(make_uniq<ConstantExpression>(timestamp_format));
column = make_uniq<FunctionExpression>("strftime", std::move(strftime_children));
}
column->alias = name;
column->SetAlias(name);
select_list.emplace_back(std::move(column));
}

Expand Down
13 changes: 7 additions & 6 deletions src/duckdb/extension/json/json_functions/json_serialize_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,34 @@ static unique_ptr<FunctionData> JsonSerializePlanBind(ClientContext &context, Sc
if (!arg->IsFoldable()) {
throw BinderException("json_serialize_plan: arguments must be constant");
}
if (arg->alias == "skip_null") {
auto &alias = arg->GetAlias();
if (alias == "skip_null") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_plan: 'skip_null' argument must be a boolean");
}
skip_if_null = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else if (arg->alias == "skip_empty") {
} else if (alias == "skip_empty") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_plan: 'skip_empty' argument must be a boolean");
}
skip_if_empty = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else if (arg->alias == "skip_default") {
} else if (alias == "skip_default") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_plan: 'skip_default' argument must be a boolean");
}
skip_if_default = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else if (arg->alias == "format") {
} else if (alias == "format") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_plan: 'format' argument must be a boolean");
}
format = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else if (arg->alias == "optimize") {
} else if (alias == "optimize") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_plan: 'optimize' argument must be a boolean");
}
optimize = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else {
throw BinderException(StringUtil::Format("json_serialize_plan: Unknown argument '%s'", arg->alias.c_str()));
throw BinderException(StringUtil::Format("json_serialize_plan: Unknown argument '%s'", alias));
}
}
return make_uniq<JsonSerializePlanBindData>(skip_if_null, skip_if_empty, skip_if_default, format, optimize);
Expand Down
11 changes: 6 additions & 5 deletions src/duckdb/extension/json/json_functions/json_serialize_sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,29 @@ static unique_ptr<FunctionData> JsonSerializeBind(ClientContext &context, Scalar
if (!arg->IsFoldable()) {
throw BinderException("json_serialize_sql: arguments must be constant");
}
if (arg->alias == "skip_null") {
auto &alias = arg->GetAlias();
if (alias == "skip_null") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_sql: 'skip_null' argument must be a boolean");
}
skip_if_null = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else if (arg->alias == "skip_empty") {
} else if (alias == "skip_empty") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_sql: 'skip_empty' argument must be a boolean");
}
skip_if_empty = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else if (arg->alias == "format") {
} else if (alias == "format") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_sql: 'format' argument must be a boolean");
}
format = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else if (arg->alias == "skip_default") {
} else if (alias == "skip_default") {
if (arg->return_type.id() != LogicalTypeId::BOOLEAN) {
throw BinderException("json_serialize_sql: 'skip_default' argument must be a boolean");
}
skip_if_default = BooleanValue::Get(ExpressionExecutor::EvaluateScalar(context, *arg));
} else {
throw BinderException(StringUtil::Format("json_serialize_sql: Unknown argument '%s'", arg->alias));
throw BinderException(StringUtil::Format("json_serialize_sql: Unknown argument '%s'", alias));
}
}
return make_uniq<JsonSerializeBindData>(skip_if_null, skip_if_empty, skip_if_default, format);
Expand Down
8 changes: 4 additions & 4 deletions src/duckdb/extension/parquet/parquet_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ static vector<unique_ptr<Expression>> ParquetWriteSelect(CopyToSelectInput &inpu
for (auto &expr : input.select_list) {

const auto &type = expr->return_type;
const auto &name = expr->alias;
const auto &name = expr->GetAlias();

// Spatial types need to be encoded into WKB when writing GeoParquet.
// But dont perform this conversion if this is a EXPORT DATABASE statement
Expand All @@ -1597,7 +1597,7 @@ static vector<unique_ptr<Expression>> ParquetWriteSelect(CopyToSelectInput &inpu
wkb_blob_type.SetAlias("WKB_BLOB");

auto cast_expr = BoundCastExpression::AddCastToType(context, std::move(expr), wkb_blob_type, false);
cast_expr->alias = name;
cast_expr->SetAlias(name);
result.push_back(std::move(cast_expr));
any_change = true;
}
Expand All @@ -1609,7 +1609,7 @@ static vector<unique_ptr<Expression>> ParquetWriteSelect(CopyToSelectInput &inpu

// Cast the column to the new type
auto cast_expr = BoundCastExpression::AddCastToType(context, std::move(expr), new_type, false);
cast_expr->alias = name;
cast_expr->SetAlias(name);
result.push_back(std::move(cast_expr));
any_change = true;
}
Expand All @@ -1622,7 +1622,7 @@ static vector<unique_ptr<Expression>> ParquetWriteSelect(CopyToSelectInput &inpu
});

auto cast_expr = BoundCastExpression::AddCastToType(context, std::move(expr), new_type, false);
cast_expr->alias = name;
cast_expr->SetAlias(name);
result.push_back(std::move(cast_expr));
any_change = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void DuckTableEntry::UndoAlter(ClientContext &context, AlterInfo &info) {
}

static void RenameExpression(ParsedExpression &expr, RenameColumnInfo &info) {
if (expr.type == ExpressionType::COLUMN_REF) {
if (expr.GetExpressionType() == ExpressionType::COLUMN_REF) {
auto &colref = expr.Cast<ColumnRefExpression>();
if (colref.column_names.back() == info.old_name) {
colref.column_names.back() = info.new_name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ string TableCatalogEntry::ColumnsToSQL(const ColumnList &columns, const vector<u
if (column_type.id() != LogicalTypeId::ANY) {
// We artificially add a cast if the type is specified, need to strip it
auto &expr = generated_expression.get();
D_ASSERT(expr.type == ExpressionType::OPERATOR_CAST);
D_ASSERT(expr.GetExpressionType() == ExpressionType::OPERATOR_CAST);
auto &cast_expr = expr.Cast<CastExpression>();
D_ASSERT(cast_expr.cast_type.id() == column_type.id());
generated_expression = *cast_expr.child;
Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/src/common/error_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void ErrorData::AddQueryLocation(QueryErrorContext error_context) {
}

void ErrorData::AddQueryLocation(const ParsedExpression &ref) {
AddQueryLocation(ref.query_location);
AddQueryLocation(ref.GetQueryLocation());
}

void ErrorData::AddQueryLocation(const TableRef &ref) {
Expand Down
4 changes: 2 additions & 2 deletions src/duckdb/src/common/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ ExceptionType Exception::StringToExceptionType(const string &type) {
}

unordered_map<string, string> Exception::InitializeExtraInfo(const Expression &expr) {
return InitializeExtraInfo(expr.query_location);
return InitializeExtraInfo(expr.GetQueryLocation());
}

unordered_map<string, string> Exception::InitializeExtraInfo(const ParsedExpression &expr) {
return InitializeExtraInfo(expr.query_location);
return InitializeExtraInfo(expr.GetQueryLocation());
}

unordered_map<string, string> Exception::InitializeExtraInfo(const QueryErrorContext &error_context) {
Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/src/common/exception/binder_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BinderException BinderException::NoMatchingFunction(const string &name, const ve
}

BinderException BinderException::Unsupported(ParsedExpression &expr, const string &message) {
auto extra_info = Exception::InitializeExtraInfo("UNSUPPORTED", expr.query_location);
auto extra_info = Exception::InitializeExtraInfo("UNSUPPORTED", expr.GetQueryLocation());
return BinderException(message, extra_info);
}

Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/src/common/hive_partitioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ GetKnownColumnValues(const string &filename, const HivePartitioningFilterInfo &f
static void ConvertKnownColRefToConstants(ClientContext &context, unique_ptr<Expression> &expr,
const unordered_map<column_t, PartitioningColumnValue> &known_column_values,
idx_t table_index) {
if (expr->type == ExpressionType::BOUND_COLUMN_REF) {
if (expr->GetExpressionType() == ExpressionType::BOUND_COLUMN_REF) {
auto &bound_colref = expr->Cast<BoundColumnRefExpression>();

// This bound column ref is for another table
Expand Down
18 changes: 16 additions & 2 deletions src/duckdb/src/execution/aggregate_hashtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,17 @@ idx_t GroupedAggregateHashTable::FindOrCreateGroupsInternal(DataChunk &groups, V
// and precompute the hash salts for faster comparison below
const auto ht_offsets = FlatVector::GetData<uint64_t>(state.ht_offsets);
const auto hash_salts = FlatVector::GetData<hash_t>(state.hash_salts);

// We also compute the occupied count, which is essentially useless.
// However, this loop is branchless, while the main lookup loop below is not.
// So, by doing the lookups here, we better amortize cache misses.
idx_t occupied_count = 0;
for (idx_t r = 0; r < chunk_size; r++) {
const auto &hash = hashes[r];
ht_offsets[r] = ApplyBitMask(hash);
D_ASSERT(ht_offsets[r] == hash % capacity);
auto &ht_offset = ht_offsets[r];
ht_offset = ApplyBitMask(hash);
occupied_count += entries[ht_offset].IsOccupied(); // Lookup
D_ASSERT(ht_offset == hash % capacity);
hash_salts[r] = ht_entry_t::ExtractSalt(hash);
}

Expand Down Expand Up @@ -671,6 +678,13 @@ idx_t GroupedAggregateHashTable::FindOrCreateGroupsInternal(DataChunk &groups, V
}
}

if (DUCKDB_UNLIKELY(occupied_count > new_entry_count + need_compare_count)) {
// We use the useless occupied_count we summed above here so the variable is used,
// and the compiler cannot optimize away the vectorized lookups above. This should never be triggered.
throw InternalException("Internal validation failed in GroupedAggregateHashTable");
}
occupied_count = 0; // Have to set to 0 for next iterations

if (new_entry_count != 0) {
// Append everything that belongs to an empty group
optional_ptr<PartitionedTupleData> data;
Expand Down
4 changes: 2 additions & 2 deletions src/duckdb/src/execution/column_binding_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ unique_ptr<Expression> ColumnBindingResolver::VisitReplace(BoundColumnRefExpress
// in verification mode
return nullptr;
}
return make_uniq<BoundReferenceExpression>(expr.alias, expr.return_type, i);
return make_uniq<BoundReferenceExpression>(expr.GetAlias(), expr.return_type, i);
}
}
// LCOV_EXCL_START
// could not bind the column reference, this should never happen and indicates a bug in the code
// generate an error message
throw InternalException("Failed to bind column reference \"%s\" [%d.%d] (bindings: %s)", expr.alias,
throw InternalException("Failed to bind column reference \"%s\" [%d.%d] (bindings: %s)", expr.GetAlias(),
expr.binding.table_index, expr.binding.column_index,
LogicalOperator::ColumnBindingsToString(bindings));
// LCOV_EXCL_STOP
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/execution/expression_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void ExpressionExecutor::Verify(const Expression &expr, Vector &vector, idx_t co

unique_ptr<ExpressionState> ExpressionExecutor::InitializeState(const Expression &expr,
ExpressionExecutorState &state) {
switch (expr.expression_class) {
switch (expr.GetExpressionClass()) {
case ExpressionClass::BOUND_REF:
return InitializeState(expr.Cast<BoundReferenceExpression>(), state);
case ExpressionClass::BOUND_BETWEEN:
Expand Down Expand Up @@ -191,7 +191,7 @@ void ExpressionExecutor::Execute(const Expression &expr, ExpressionState *state,
"ExpressionExecutor::Execute called with a result vector of type %s that does not match expression type %s",
result.GetType(), expr.return_type);
}
switch (expr.expression_class) {
switch (expr.GetExpressionClass()) {
case ExpressionClass::BOUND_BETWEEN:
Execute(expr.Cast<BoundBetweenExpression>(), state, sel, count, result);
break;
Expand Down Expand Up @@ -235,7 +235,7 @@ idx_t ExpressionExecutor::Select(const Expression &expr, ExpressionState *state,
}
D_ASSERT(true_sel || false_sel);
D_ASSERT(expr.return_type.id() == LogicalTypeId::BOOLEAN);
switch (expr.expression_class) {
switch (expr.GetExpressionClass()) {
#ifndef DUCKDB_SMALLER_BINARY
case ExpressionClass::BOUND_BETWEEN:
return Select(expr.Cast<BoundBetweenExpression>(), state, sel, count, true_sel, false_sel);
Expand Down
4 changes: 2 additions & 2 deletions src/duckdb/src/execution/expression_executor/execute_cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ void ExpressionExecutor::Execute(const BoundCastExpression &expr, ExpressionStat
if (expr.try_cast) {
string error_message;
CastParameters parameters(expr.bound_cast.cast_data.get(), false, &error_message, lstate);
parameters.query_location = expr.query_location;
parameters.query_location = expr.GetQueryLocation();
expr.bound_cast.function(child, result, count, parameters);
} else {
// cast it to the type specified by the cast expression
D_ASSERT(result.GetType() == expr.return_type);
CastParameters parameters(expr.bound_cast.cast_data.get(), false, nullptr, lstate);
parameters.query_location = expr.query_location;
parameters.query_location = expr.GetQueryLocation();
expr.bound_cast.function(child, result, count, parameters);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ExpressionExecutor::Execute(const BoundComparisonExpression &expr, Expressi
Execute(*expr.left, state->child_states[0].get(), sel, count, left);
Execute(*expr.right, state->child_states[1].get(), sel, count, right);

switch (expr.type) {
switch (expr.GetExpressionType()) {
case ExpressionType::COMPARE_EQUAL:
VectorOperations::Equals(left, right, result, count);
break;
Expand Down Expand Up @@ -357,7 +357,7 @@ idx_t ExpressionExecutor::Select(const BoundComparisonExpression &expr, Expressi
Execute(*expr.left, state->child_states[0].get(), sel, count, left);
Execute(*expr.right, state->child_states[1].get(), sel, count, right);

switch (expr.type) {
switch (expr.GetExpressionType()) {
case ExpressionType::COMPARE_EQUAL:
return VectorOperations::Equals(left, right, sel, count, true_sel, false_sel);
case ExpressionType::COMPARE_NOTEQUAL:
Expand Down
Loading

0 comments on commit 25c7873

Please sign in to comment.