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>
|
|
|
|
#include <Parsers/ASTWithAlias.h>
|
2019-05-22 00:57:34 +00:00
|
|
|
#include <Parsers/TokenIterator.h>
|
2021-06-14 04:13:35 +00:00
|
|
|
#include <Common/FieldVisitorDump.h>
|
2020-12-04 02:15:44 +00:00
|
|
|
|
2019-05-22 19:59:18 +00:00
|
|
|
#include <optional>
|
2010-06-24 19:12:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-12-04 02:15:44 +00:00
|
|
|
/// Literal (atomic) - number, string, NULL
|
2014-07-03 22:39:13 +00:00
|
|
|
class ASTLiteral : public ASTWithAlias
|
2010-06-24 19:12:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-12-04 02:15:44 +00:00
|
|
|
explicit ASTLiteral(Field && value_) : value(value_) {}
|
|
|
|
explicit ASTLiteral(const Field & value_) : value(value_) {}
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
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;
|
|
|
|
|
2020-04-14 17:41:06 +00:00
|
|
|
/*
|
|
|
|
* The name of the column corresponding to this literal. Only used to
|
|
|
|
* disambiguate the literal columns with the same display name that are
|
|
|
|
* created at the expression analyzer stage. In the future, we might want to
|
|
|
|
* have a full separation between display names and column identifiers. For
|
|
|
|
* now, this field is effectively just some private EA data.
|
|
|
|
*/
|
|
|
|
String unique_column_name;
|
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** Get the text that identifies this element. */
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char delim) const override { return "Literal" + (delim + 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
|
|
|
|
2019-01-23 13:20:03 +00:00
|
|
|
void updateTreeHashImpl(SipHash & hash_state) const override;
|
|
|
|
|
2015-08-05 21:38:31 +00:00
|
|
|
protected:
|
2020-11-09 16:05:40 +00:00
|
|
|
void formatImplWithoutAlias(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
2017-12-01 18:36:55 +00:00
|
|
|
|
2018-06-27 16:34:11 +00:00
|
|
|
void appendColumnNameImpl(WriteBuffer & ostr) const override;
|
2021-06-16 17:56:20 +00:00
|
|
|
void appendColumnNameImpl(WriteBuffer & ostr, const Settings & settings) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// Legacy version of 'appendColumnNameImpl'. It differs only with tuple literals.
|
|
|
|
/// It's only needed to continue working of queries with tuple literals
|
|
|
|
/// in distributed tables while rolling update.
|
|
|
|
void appendColumnNameImplLegacy(WriteBuffer & ostr) const;
|
2010-06-24 19:12:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|