mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 04:22:03 +00:00
48 lines
1002 B
C++
48 lines
1002 B
C++
#pragma once
|
|
|
|
#include <Core/Field.h>
|
|
#include <DataTypes/IDataType.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Immutable constant value representation during analysis stage.
|
|
* Some query nodes can be represented by constant (scalar subqueries, functions with constant arguments).
|
|
*/
|
|
class ConstantValue;
|
|
using ConstantValuePtr = std::shared_ptr<ConstantValue>;
|
|
|
|
class ConstantValue
|
|
{
|
|
public:
|
|
ConstantValue(Field value_, DataTypePtr data_type_)
|
|
: value(std::move(value_))
|
|
, data_type(std::move(data_type_))
|
|
{}
|
|
|
|
const Field & getValue() const
|
|
{
|
|
return value;
|
|
}
|
|
|
|
const DataTypePtr & getType() const
|
|
{
|
|
return data_type;
|
|
}
|
|
private:
|
|
Field value;
|
|
DataTypePtr data_type;
|
|
};
|
|
|
|
inline bool operator==(const ConstantValue & lhs, const ConstantValue & rhs)
|
|
{
|
|
return lhs.getValue() == rhs.getValue() && lhs.getType()->equals(*rhs.getType());
|
|
}
|
|
|
|
inline bool operator!=(const ConstantValue & lhs, const ConstantValue & rhs)
|
|
{
|
|
return !(lhs == rhs);
|
|
}
|
|
|
|
}
|