ClickHouse/src/Analyzer/InterpolateNode.h

71 lines
2.0 KiB
C++
Raw Normal View History

2022-09-03 16:20:09 +00:00
#pragma once
#include <Analyzer/IQueryTreeNode.h>
#include <Analyzer/ListNode.h>
namespace DB
{
/** Interpolate node represents expression interpolation in INTERPOLATE section that is part of ORDER BY section in query tree.
2022-10-12 13:46:50 +00:00
*
* Example: SELECT * FROM test_table ORDER BY id WITH FILL INTERPOLATE (value AS value + 1);
2022-09-03 17:34:52 +00:00
* value - expression to interpolate.
* value + 1 - interpolate expression.
2022-09-03 16:20:09 +00:00
*/
class InterpolateNode;
using InterpolateNodePtr = std::shared_ptr<InterpolateNode>;
2022-09-03 16:20:09 +00:00
class InterpolateNode final : public IQueryTreeNode
2022-09-03 16:20:09 +00:00
{
public:
/// Initialize interpolate node with expression and interpolate expression
explicit InterpolateNode(QueryTreeNodePtr expression_, QueryTreeNodePtr interpolate_expression_);
2022-09-03 16:20:09 +00:00
2022-10-07 10:44:28 +00:00
/// Get expression to interpolate
2022-09-03 16:20:09 +00:00
const QueryTreeNodePtr & getExpression() const
{
return children[expression_child_index];
}
2022-10-07 10:44:28 +00:00
/// Get expression to interpolate
2022-09-03 16:20:09 +00:00
QueryTreeNodePtr & getExpression()
{
return children[expression_child_index];
}
2022-10-07 10:44:28 +00:00
/// Get interpolate expression
2022-09-03 16:20:09 +00:00
const QueryTreeNodePtr & getInterpolateExpression() const
{
return children[interpolate_expression_child_index];
}
2022-10-07 10:44:28 +00:00
/// Get interpolate expression
2022-09-03 16:20:09 +00:00
QueryTreeNodePtr & getInterpolateExpression()
{
return children[interpolate_expression_child_index];
}
QueryTreeNodeType getNodeType() const override
{
return QueryTreeNodeType::INTERPOLATE;
2022-09-03 16:20:09 +00:00
}
void dumpTreeImpl(WriteBuffer & buffer, FormatState & format_state, size_t indent) const override;
protected:
2022-09-03 16:20:09 +00:00
bool isEqualImpl(const IQueryTreeNode & rhs) const override;
void updateTreeHashImpl(HashState & hash_state) const override;
QueryTreeNodePtr cloneImpl() const override;
2023-03-14 09:14:58 +00:00
ASTPtr toASTImpl(const ConvertToASTOptions & options) const override;
2022-09-03 16:20:09 +00:00
private:
static constexpr size_t expression_child_index = 0;
static constexpr size_t interpolate_expression_child_index = 1;
static constexpr size_t children_size = interpolate_expression_child_index + 1;
};
}