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>
|
2010-06-24 19:12:10 +00:00
|
|
|
#include <DB/Parsers/IAST.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Литерал (атомарный) - число, строка, NULL
|
|
|
|
*/
|
|
|
|
class ASTLiteral : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Field value;
|
2011-08-12 18:27:39 +00:00
|
|
|
/// тип
|
|
|
|
DataTypePtr type;
|
2011-11-06 04:21:09 +00:00
|
|
|
/// алиас, если есть
|
|
|
|
String alias;
|
2010-06-24 19:12:10 +00:00
|
|
|
|
2010-06-25 16:36:13 +00:00
|
|
|
ASTLiteral() {}
|
2011-08-13 21:05:18 +00:00
|
|
|
ASTLiteral(StringRange range_, const Field & value_) : IAST(range_), value(value_) {}
|
2011-09-25 03:37:09 +00:00
|
|
|
|
2012-12-27 16:23:12 +00:00
|
|
|
String getColumnName() const { return boost::apply_visitor(FieldVisitorToString(), value); }
|
2011-11-06 04:21:09 +00:00
|
|
|
|
2012-12-27 16:23:12 +00:00
|
|
|
String getAlias() const { return alias.empty() ? getColumnName() : alias; }
|
2010-06-24 19:12:10 +00:00
|
|
|
|
2011-08-09 19:19:00 +00:00
|
|
|
/** Получить текст, который идентифицирует этот элемент. */
|
2012-12-27 16:23:12 +00:00
|
|
|
String getID() const { return "Literal_" + boost::apply_visitor(FieldVisitorDump(), value); }
|
2011-12-12 06:15:34 +00:00
|
|
|
|
|
|
|
ASTPtr clone() const { return new ASTLiteral(*this); }
|
2010-06-24 19:12:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|