ClickHouse/dbms/src/Parsers/ASTLiteral.h

42 lines
1.0 KiB
C++
Raw Normal View History

2011-09-26 01:50:32 +00:00
#pragma once
2010-06-24 19:12:10 +00:00
#include <Core/Field.h>
#include <Common/FieldVisitors.h>
#include <Parsers/ASTWithAlias.h>
2019-05-22 00:57:34 +00:00
#include <Parsers/TokenIterator.h>
2010-06-24 19:12:10 +00:00
namespace DB
{
2017-05-27 17:27:16 +00:00
/** Literal (atomic) - number, string, NULL
2010-06-24 19:12:10 +00:00
*/
2014-07-03 22:39:13 +00:00
class ASTLiteral : public ASTWithAlias
2010-06-24 19:12:10 +00:00
{
public:
Field value;
2010-06-24 19:12:10 +00:00
2019-05-22 00:57:34 +00:00
/// For ConstantExpressionTemplate
std::optional<TokenIterator> begin;
std::optional<TokenIterator> end;
2018-02-26 03:37:08 +00:00
ASTLiteral(const Field & value_) : value(value_) {}
2011-09-25 03:37:09 +00:00
2017-05-27 17:27:16 +00:00
/** Get the text that identifies this element. */
String getID(char delim) const override { return "Literal" + (delim + applyVisitor(FieldVisitorDump(), value)); }
2011-12-12 06:15:34 +00:00
ASTPtr clone() const override { return std::make_shared<ASTLiteral>(*this); }
void updateTreeHashImpl(SipHash & hash_state) const override;
protected:
2017-12-01 18:36:55 +00:00
void formatImplWithoutAlias(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
{
settings.ostr << applyVisitor(FieldVisitorToString(), value);
}
2017-12-01 18:36:55 +00:00
void appendColumnNameImpl(WriteBuffer & ostr) const override;
2010-06-24 19:12:10 +00:00
};
}