tests_fuzz/ir/
create_expr.rsuse std::collections::HashMap;
use std::fmt::Display;
use datatypes::value::Value;
use derive_builder::Builder;
use partition::partition::PartitionDef;
use serde::{Deserialize, Serialize};
use crate::ir::{Column, Ident};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub enum ColumnOption {
Null,
NotNull,
DefaultValue(Value),
DefaultFn(String),
TimeIndex,
PrimaryKey,
}
impl Display for ColumnOption {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ColumnOption::Null => write!(f, "NULL"),
ColumnOption::NotNull => write!(f, "NOT NULL"),
ColumnOption::DefaultFn(s) => write!(f, "DEFAULT {}", s),
ColumnOption::DefaultValue(s) => match s {
Value::String(value) => {
write!(f, "DEFAULT \'{}\'", value.as_utf8())
}
_ => write!(f, "DEFAULT {}", s),
},
ColumnOption::TimeIndex => write!(f, "TIME INDEX"),
ColumnOption::PrimaryKey => write!(f, "PRIMARY KEY"),
}
}
}
#[derive(Debug, Builder, Clone, Serialize, Deserialize)]
pub struct CreateTableExpr {
#[builder(setter(into))]
pub table_name: Ident,
pub columns: Vec<Column>,
#[builder(default)]
pub if_not_exists: bool,
#[builder(default, setter(into))]
pub partition: Option<PartitionDef>,
#[builder(default, setter(into))]
pub engine: String,
#[builder(default, setter(into))]
pub options: HashMap<String, Value>,
pub primary_keys: Vec<usize>,
}
#[derive(Debug, Builder, Clone, Serialize, Deserialize)]
pub struct CreateDatabaseExpr {
#[builder(setter(into))]
pub database_name: Ident,
#[builder(default)]
pub if_not_exists: bool,
}