1#include "duckdb/parser/expression/constant_expression.hpp"
2
3#include "duckdb/common/exception.hpp"
4#include "duckdb/common/types/hash.hpp"
5#include "duckdb/common/value_operations/value_operations.hpp"
6
7using namespace duckdb;
8using namespace std;
9
10ConstantExpression::ConstantExpression(SQLType sql_type, Value val)
11 : ParsedExpression(ExpressionType::VALUE_CONSTANT, ExpressionClass::CONSTANT), value(val), sql_type(sql_type) {
12}
13
14string ConstantExpression::ToString() const {
15 return value.ToString();
16}
17
18bool ConstantExpression::Equals(const ConstantExpression *a, const ConstantExpression *b) {
19 return a->value == b->value;
20}
21
22hash_t ConstantExpression::Hash() const {
23 return ParsedExpression::Hash();
24}
25
26unique_ptr<ParsedExpression> ConstantExpression::Copy() const {
27 auto copy = make_unique<ConstantExpression>(sql_type, value);
28 copy->CopyProperties(*this);
29 return move(copy);
30}
31
32void ConstantExpression::Serialize(Serializer &serializer) {
33 ParsedExpression::Serialize(serializer);
34 value.Serialize(serializer);
35 sql_type.Serialize(serializer);
36}
37
38unique_ptr<ParsedExpression> ConstantExpression::Deserialize(ExpressionType type, Deserializer &source) {
39 Value value = Value::Deserialize(source);
40 auto sql_type = SQLType::Deserialize(source);
41 return make_unique<ConstantExpression>(sql_type, value);
42}
43