2022-07-14 11:20:16 +00:00
|
|
|
#include <Analyzer/IdentifierNode.h>
|
|
|
|
|
2023-03-24 02:44:52 +00:00
|
|
|
#include <Common/assert_cast.h>
|
2022-07-14 11:20:16 +00:00
|
|
|
#include <Common/SipHash.h>
|
|
|
|
|
|
|
|
#include <IO/WriteBufferFromString.h>
|
|
|
|
#include <IO/Operators.h>
|
|
|
|
|
|
|
|
#include <Parsers/ASTIdentifier.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-10-07 10:44:28 +00:00
|
|
|
IdentifierNode::IdentifierNode(Identifier identifier_)
|
|
|
|
: IQueryTreeNode(children_size)
|
|
|
|
, identifier(std::move(identifier_))
|
|
|
|
{}
|
|
|
|
|
|
|
|
IdentifierNode::IdentifierNode(Identifier identifier_, TableExpressionModifiers table_expression_modifiers_)
|
|
|
|
: IQueryTreeNode(children_size)
|
|
|
|
, identifier(std::move(identifier_))
|
|
|
|
, table_expression_modifiers(std::move(table_expression_modifiers_))
|
|
|
|
{}
|
|
|
|
|
2022-07-19 10:54:45 +00:00
|
|
|
void IdentifierNode::dumpTreeImpl(WriteBuffer & buffer, FormatState & format_state, size_t indent) const
|
2022-07-14 11:20:16 +00:00
|
|
|
{
|
2022-07-19 10:54:45 +00:00
|
|
|
buffer << std::string(indent, ' ') << "IDENTIFIER id: " << format_state.getNodeId(this);
|
|
|
|
|
|
|
|
if (hasAlias())
|
|
|
|
buffer << ", alias: " << getAlias();
|
|
|
|
|
|
|
|
buffer << ", identifier: " << identifier.getFullName();
|
2022-09-04 15:20:59 +00:00
|
|
|
|
|
|
|
if (table_expression_modifiers)
|
|
|
|
{
|
|
|
|
buffer << ", ";
|
|
|
|
table_expression_modifiers->dump(buffer);
|
|
|
|
}
|
2022-07-14 11:20:16 +00:00
|
|
|
}
|
|
|
|
|
2022-07-15 13:32:53 +00:00
|
|
|
bool IdentifierNode::isEqualImpl(const IQueryTreeNode & rhs) const
|
|
|
|
{
|
|
|
|
const auto & rhs_typed = assert_cast<const IdentifierNode &>(rhs);
|
2023-02-25 19:16:51 +00:00
|
|
|
return identifier == rhs_typed.identifier && table_expression_modifiers == rhs_typed.table_expression_modifiers;
|
2022-07-15 13:32:53 +00:00
|
|
|
}
|
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
void IdentifierNode::updateTreeHashImpl(HashState & state) const
|
|
|
|
{
|
|
|
|
const auto & identifier_name = identifier.getFullName();
|
|
|
|
state.update(identifier_name.size());
|
|
|
|
state.update(identifier_name);
|
2022-09-04 15:20:59 +00:00
|
|
|
|
|
|
|
if (table_expression_modifiers)
|
|
|
|
table_expression_modifiers->updateTreeHash(state);
|
2022-07-14 11:20:16 +00:00
|
|
|
}
|
|
|
|
|
2022-10-10 10:25:58 +00:00
|
|
|
QueryTreeNodePtr IdentifierNode::cloneImpl() const
|
2022-07-14 11:20:16 +00:00
|
|
|
{
|
2022-10-10 10:25:58 +00:00
|
|
|
return std::make_shared<IdentifierNode>(identifier);
|
2022-07-14 11:20:16 +00:00
|
|
|
}
|
|
|
|
|
2023-03-14 09:14:58 +00:00
|
|
|
ASTPtr IdentifierNode::toASTImpl(const ConvertToASTOptions & /* options */) const
|
2022-07-14 11:20:16 +00:00
|
|
|
{
|
2022-10-10 10:25:58 +00:00
|
|
|
auto identifier_parts = identifier.getParts();
|
|
|
|
return std::make_shared<ASTIdentifier>(std::move(identifier_parts));
|
2022-07-14 11:20:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|