2022-09-15 11:45:01 +00:00
|
|
|
#include <Analyzer/InterpolateNode.h>
|
2022-09-03 16:20:09 +00:00
|
|
|
|
|
|
|
#include <Common/SipHash.h>
|
|
|
|
|
|
|
|
#include <IO/WriteBufferFromString.h>
|
|
|
|
#include <IO/Operators.h>
|
|
|
|
|
|
|
|
#include <Parsers/ASTInterpolateElement.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-09-15 11:45:01 +00:00
|
|
|
InterpolateNode::InterpolateNode(QueryTreeNodePtr expression_, QueryTreeNodePtr interpolate_expression_)
|
2022-10-07 10:44:28 +00:00
|
|
|
: IQueryTreeNode(children_size)
|
2022-09-03 16:20:09 +00:00
|
|
|
{
|
|
|
|
children[expression_child_index] = std::move(expression_);
|
|
|
|
children[interpolate_expression_child_index] = std::move(interpolate_expression_);
|
|
|
|
}
|
|
|
|
|
2022-09-15 11:45:01 +00:00
|
|
|
String InterpolateNode::getName() const
|
2022-09-03 16:20:09 +00:00
|
|
|
{
|
|
|
|
String result = getExpression()->getName();
|
|
|
|
result += " AS ";
|
|
|
|
result += getInterpolateExpression()->getName();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-09-15 11:45:01 +00:00
|
|
|
void InterpolateNode::dumpTreeImpl(WriteBuffer & buffer, FormatState & format_state, size_t indent) const
|
2022-09-03 16:20:09 +00:00
|
|
|
{
|
|
|
|
buffer << std::string(indent, ' ') << "INTERPOLATE_COLUMN id: " << format_state.getNodeId(this);
|
|
|
|
|
|
|
|
buffer << '\n' << std::string(indent + 2, ' ') << "EXPRESSION\n";
|
|
|
|
getExpression()->dumpTreeImpl(buffer, format_state, indent + 4);
|
|
|
|
|
|
|
|
buffer << '\n' << std::string(indent + 2, ' ') << "INTERPOLATE_EXPRESSION\n";
|
|
|
|
getInterpolateExpression()->dumpTreeImpl(buffer, format_state, indent + 4);
|
|
|
|
}
|
|
|
|
|
2022-09-15 11:45:01 +00:00
|
|
|
bool InterpolateNode::isEqualImpl(const IQueryTreeNode &) const
|
2022-09-03 16:20:09 +00:00
|
|
|
{
|
|
|
|
/// No state in interpolate column node
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-15 11:45:01 +00:00
|
|
|
void InterpolateNode::updateTreeHashImpl(HashState &) const
|
2022-09-03 16:20:09 +00:00
|
|
|
{
|
|
|
|
/// No state in interpolate column node
|
|
|
|
}
|
|
|
|
|
2022-10-10 10:25:58 +00:00
|
|
|
QueryTreeNodePtr InterpolateNode::cloneImpl() const
|
|
|
|
{
|
|
|
|
return std::make_shared<InterpolateNode>(nullptr /*expression*/, nullptr /*interpolate_expression*/);
|
|
|
|
}
|
|
|
|
|
2022-09-15 11:45:01 +00:00
|
|
|
ASTPtr InterpolateNode::toASTImpl() const
|
2022-09-03 16:20:09 +00:00
|
|
|
{
|
|
|
|
auto result = std::make_shared<ASTInterpolateElement>();
|
|
|
|
result->column = getExpression()->toAST()->getColumnName();
|
|
|
|
result->children.push_back(getInterpolateExpression()->toAST());
|
|
|
|
result->expr = result->children.back();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|