2019-10-09 13:02:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
2020-05-22 13:29:33 +00:00
|
|
|
#include <Storages/DataDestinationType.h>
|
2020-05-28 15:33:44 +00:00
|
|
|
#include <Storages/TTLMode.h>
|
2019-10-09 13:02:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-04-27 14:47:59 +00:00
|
|
|
|
2019-10-09 13:02:05 +00:00
|
|
|
/** Element of TTL expression.
|
|
|
|
*/
|
|
|
|
class ASTTTLElement : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2020-05-12 14:27:00 +00:00
|
|
|
TTLMode mode;
|
2020-05-22 13:29:33 +00:00
|
|
|
DataDestinationType destination_type;
|
2019-10-09 13:02:05 +00:00
|
|
|
String destination_name;
|
2022-02-10 16:18:01 +00:00
|
|
|
bool if_exists = false;
|
2019-10-09 13:02:05 +00:00
|
|
|
|
2020-05-24 20:21:23 +00:00
|
|
|
ASTs group_by_key;
|
2021-01-12 00:40:07 +00:00
|
|
|
ASTs group_by_assignments;
|
2019-10-09 13:02:05 +00:00
|
|
|
|
2020-08-31 11:35:53 +00:00
|
|
|
ASTPtr recompression_codec;
|
|
|
|
|
2022-02-10 16:18:01 +00:00
|
|
|
ASTTTLElement(TTLMode mode_, DataDestinationType destination_type_, const String & destination_name_, bool if_exists_)
|
2020-05-12 20:44:48 +00:00
|
|
|
: mode(mode_)
|
2020-04-27 14:47:59 +00:00
|
|
|
, destination_type(destination_type_)
|
2019-10-09 13:02:05 +00:00
|
|
|
, destination_name(destination_name_)
|
2022-02-10 16:18:01 +00:00
|
|
|
, if_exists(if_exists_)
|
2020-05-12 14:27:00 +00:00
|
|
|
, ttl_expr_pos(-1)
|
|
|
|
, where_expr_pos(-1)
|
2019-10-09 13:02:05 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
String getID(char) const override { return "TTLElement"; }
|
|
|
|
|
2020-04-27 14:47:59 +00:00
|
|
|
ASTPtr clone() const override;
|
|
|
|
|
2022-03-13 12:05:14 +00:00
|
|
|
ASTPtr ttl() const { return getExpression(ttl_expr_pos); }
|
|
|
|
ASTPtr where() const { return getExpression(where_expr_pos); }
|
2020-04-27 14:47:59 +00:00
|
|
|
|
2020-05-12 14:27:00 +00:00
|
|
|
void setTTL(ASTPtr && ast) { setExpression(ttl_expr_pos, std::forward<ASTPtr>(ast)); }
|
|
|
|
void setWhere(ASTPtr && ast) { setExpression(where_expr_pos, std::forward<ASTPtr>(ast)); }
|
2019-10-09 13:02:05 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2020-04-27 14:47:59 +00:00
|
|
|
|
2020-05-12 20:44:48 +00:00
|
|
|
private:
|
2020-05-12 14:27:00 +00:00
|
|
|
int ttl_expr_pos;
|
|
|
|
int where_expr_pos;
|
|
|
|
|
2020-05-12 20:44:48 +00:00
|
|
|
void setExpression(int & pos, ASTPtr && ast);
|
2020-05-12 14:27:00 +00:00
|
|
|
ASTPtr getExpression(int pos, bool clone = false) const;
|
2019-10-09 13:02:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|