2022-07-14 11:20:16 +00:00
|
|
|
#include <Analyzer/ListNode.h>
|
|
|
|
|
|
|
|
#include <Common/SipHash.h>
|
|
|
|
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <IO/WriteHelpers.h>
|
|
|
|
#include <IO/Operators.h>
|
|
|
|
|
|
|
|
#include <Parsers/ASTExpressionList.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-10-07 10:44:28 +00:00
|
|
|
ListNode::ListNode()
|
|
|
|
: IQueryTreeNode(0 /*children_size*/)
|
|
|
|
{}
|
|
|
|
|
2022-08-15 16:34:10 +00:00
|
|
|
ListNode::ListNode(QueryTreeNodes nodes)
|
2022-10-07 10:44:28 +00:00
|
|
|
: IQueryTreeNode(0 /*children_size*/)
|
2022-08-15 16:34:10 +00:00
|
|
|
{
|
|
|
|
children = std::move(nodes);
|
|
|
|
}
|
|
|
|
|
2022-07-19 10:54:45 +00:00
|
|
|
void ListNode::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, ' ') << "LIST id: " << format_state.getNodeId(this);
|
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
size_t children_size = children.size();
|
2022-07-19 10:54:45 +00:00
|
|
|
buffer << ", nodes: " << children_size << '\n';
|
2022-07-14 11:20:16 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < children_size; ++i)
|
|
|
|
{
|
|
|
|
const auto & node = children[i];
|
2022-07-19 10:54:45 +00:00
|
|
|
node->dumpTreeImpl(buffer, format_state, indent + 2);
|
2022-07-14 11:20:16 +00:00
|
|
|
|
|
|
|
if (i + 1 != children_size)
|
|
|
|
buffer << '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String ListNode::getName() const
|
|
|
|
{
|
|
|
|
if (children.empty())
|
|
|
|
return "";
|
|
|
|
|
|
|
|
std::string result;
|
|
|
|
for (const auto & node : children)
|
|
|
|
{
|
|
|
|
result += node->getName();
|
|
|
|
result += ", ";
|
|
|
|
}
|
|
|
|
|
|
|
|
result.pop_back();
|
|
|
|
result.pop_back();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-07-15 13:32:53 +00:00
|
|
|
bool ListNode::isEqualImpl(const IQueryTreeNode &) const
|
|
|
|
{
|
|
|
|
/// No state
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
void ListNode::updateTreeHashImpl(HashState &) const
|
|
|
|
{
|
2022-07-15 13:32:53 +00:00
|
|
|
/// No state
|
2022-07-14 11:20:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ASTPtr ListNode::toASTImpl() const
|
|
|
|
{
|
|
|
|
auto expression_list_ast = std::make_shared<ASTExpressionList>();
|
|
|
|
|
|
|
|
size_t children_size = children.size();
|
|
|
|
expression_list_ast->children.resize(children_size);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < children_size; ++i)
|
|
|
|
expression_list_ast->children[i] = children[i]->toAST();
|
|
|
|
|
|
|
|
return expression_list_ast;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryTreeNodePtr ListNode::cloneImpl() const
|
|
|
|
{
|
|
|
|
return std::make_shared<ListNode>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|