Skip to main content

tests_fuzz/ir/
repartition_expr.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use partition::expr::PartitionExpr;
16use serde::{Deserialize, Serialize};
17
18use crate::ir::Ident;
19use crate::ir::create_expr::PartitionDef;
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct SplitPartitionExpr {
23    pub table_name: Ident,
24    pub target: PartitionExpr,
25    pub into: Vec<PartitionExpr>,
26    #[serde(default = "default_wait")]
27    pub wait: bool,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct MergePartitionExpr {
32    pub table_name: Ident,
33    pub targets: Vec<PartitionExpr>,
34    #[serde(default = "default_wait")]
35    pub wait: bool,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct AlterTablePartitionsExpr {
40    pub table_name: Ident,
41    pub partition: PartitionDef,
42    #[serde(default = "default_wait")]
43    pub wait: bool,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
47pub enum RepartitionExpr {
48    Split(SplitPartitionExpr),
49    Merge(MergePartitionExpr),
50    AlterPartitions(AlterTablePartitionsExpr),
51}
52
53const fn default_wait() -> bool {
54    true
55}