ClickHouse/dbms/include/DB/Parsers/ASTLiteral.h

38 lines
955 B
C
Raw Normal View History

2011-09-26 01:50:32 +00:00
#pragma once
2010-06-24 19:12:10 +00:00
#include <DB/Core/Field.h>
2011-08-12 18:27:39 +00:00
#include <DB/DataTypes/IDataType.h>
2014-07-03 22:39:13 +00:00
#include <DB/Parsers/ASTWithAlias.h>
2010-06-24 19:12:10 +00:00
namespace DB
{
/** Литерал (атомарный) - число, строка, NULL
*/
2014-07-03 22:39:13 +00:00
class ASTLiteral : public ASTWithAlias
2010-06-24 19:12:10 +00:00
{
public:
Field value;
2011-08-12 18:27:39 +00:00
/// тип
DataTypePtr type;
2010-06-24 19:12:10 +00:00
2014-12-17 15:26:24 +00:00
ASTLiteral() = default;
ASTLiteral(const StringRange range_, const Field & value_) : ASTWithAlias(range_), value(value_) {}
2011-09-25 03:37:09 +00:00
String getColumnName() const override;
2011-11-06 04:21:09 +00:00
2011-08-09 19:19:00 +00:00
/** Получить текст, который идентифицирует этот элемент. */
2014-12-17 15:26:24 +00:00
String getID() const override { return "Literal_" + apply_visitor(FieldVisitorDump(), value); }
2011-12-12 06:15:34 +00:00
2014-12-17 15:26:24 +00:00
ASTPtr clone() const override { return new ASTLiteral(*this); }
protected:
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
{
2015-08-06 04:28:59 +00:00
settings.ostr << apply_visitor(FieldVisitorToString(), value);
}
2010-06-24 19:12:10 +00:00
};
}