1#include "duckdb/parser/expression/conjunction_expression.hpp"
2#include "duckdb/planner/expression/bound_cast_expression.hpp"
3#include "duckdb/planner/expression/bound_conjunction_expression.hpp"
4#include "duckdb/planner/expression_binder.hpp"
5
6using namespace duckdb;
7using namespace std;
8
9BindResult ExpressionBinder::BindExpression(ConjunctionExpression &expr, idx_t depth) {
10 // first try to bind the children of the case expression
11 string error;
12 for (idx_t i = 0; i < expr.children.size(); i++) {
13 BindChild(expr.children[i], depth, error);
14 }
15 if (!error.empty()) {
16 return BindResult(error);
17 }
18 // the children have been successfully resolved
19 // cast the input types to boolean (if necessary)
20 // and construct the bound conjunction expression
21 auto result = make_unique<BoundConjunctionExpression>(expr.type);
22 for (auto &child_expr : expr.children) {
23 auto &child = (BoundExpression &)*child_expr;
24 result->children.push_back(
25 BoundCastExpression::AddCastToType(move(child.expr), child.sql_type, SQLType(SQLTypeId::BOOLEAN)));
26 }
27 // now create the bound conjunction expression
28 return BindResult(move(result), SQLType(SQLTypeId::BOOLEAN));
29}
30