2011-09-26 01:50:32 +00:00
|
|
|
#pragma once
|
2010-06-24 19:12:10 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Field.h>
|
2017-11-24 13:55:31 +00:00
|
|
|
#include <Common/FieldVisitors.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTWithAlias.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:
|
2017-04-01 07:20:54 +00:00
|
|
|
Field value;
|
2010-06-24 19:12:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTLiteral() = default;
|
|
|
|
ASTLiteral(const StringRange range_, const Field & value_) : ASTWithAlias(range_), 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. */
|
2017-04-01 07:20:54 +00:00
|
|
|
String getID() const override { return "Literal_" + applyVisitor(FieldVisitorDump(), value); }
|
2011-12-12 06:15:34 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTPtr clone() const override { return std::make_shared<ASTLiteral>(*this); }
|
2015-08-05 21:38:31 +00:00
|
|
|
|
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
|
|
|
settings.ostr << applyVisitor(FieldVisitorToString(), value);
|
|
|
|
}
|
2017-08-10 14:46:46 +00:00
|
|
|
String getColumnNameImpl() const override;
|
2010-06-24 19:12:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|