1#include "duckdb/planner/expression/bound_lambda_expression.hpp"
2#include "duckdb/common/string_util.hpp"
3
4namespace duckdb {
5
6BoundLambdaExpression::BoundLambdaExpression(ExpressionType type_p, LogicalType return_type_p,
7 unique_ptr<Expression> lambda_expr_p, idx_t parameter_count_p)
8 : Expression(type_p, ExpressionClass::BOUND_LAMBDA, std::move(return_type_p)),
9 lambda_expr(std::move(lambda_expr_p)), parameter_count(parameter_count_p) {
10}
11
12string BoundLambdaExpression::ToString() const {
13 return lambda_expr->ToString();
14}
15
16bool BoundLambdaExpression::Equals(const BaseExpression &other_p) const {
17 if (!Expression::Equals(other: other_p)) {
18 return false;
19 }
20 auto &other = other_p.Cast<BoundLambdaExpression>();
21 if (!Expression::Equals(left: *lambda_expr, right: *other.lambda_expr)) {
22 return false;
23 }
24 if (!Expression::ListEquals(left: captures, right: other.captures)) {
25 return false;
26 }
27 if (parameter_count != other.parameter_count) {
28 return false;
29 }
30 return true;
31}
32
33unique_ptr<Expression> BoundLambdaExpression::Copy() {
34 auto copy = make_uniq<BoundLambdaExpression>(args&: type, args&: return_type, args: lambda_expr->Copy(), args&: parameter_count);
35 for (auto &capture : captures) {
36 copy->captures.push_back(x: capture->Copy());
37 }
38 return std::move(copy);
39}
40
41void BoundLambdaExpression::Serialize(FieldWriter &writer) const {
42 throw NotImplementedException(ExpressionTypeToString(type));
43}
44
45} // namespace duckdb
46