quill_sql/catalog/
column.rs1use derive_with::With;
2use std::sync::Arc;
3
4use crate::catalog::DataType;
5use crate::utils::scalar::ScalarValue;
6use crate::utils::table_ref::TableReference;
7
8pub type ColumnRef = Arc<Column>;
9
10#[derive(Debug, Clone, With)]
11pub struct Column {
12 pub relation: Option<TableReference>,
13 pub name: String,
14 pub data_type: DataType,
15 pub nullable: bool,
16 pub default: ScalarValue,
17}
18
19impl PartialEq for Column {
20 fn eq(&self, other: &Self) -> bool {
21 self.name == other.name && self.data_type == other.data_type
22 }
23}
24
25impl Eq for Column {}
26
27impl Column {
28 pub fn new(name: impl Into<String>, data_type: DataType, nullable: bool) -> Self {
29 Self {
30 relation: None,
31 name: name.into(),
32 data_type,
33 nullable,
34 default: ScalarValue::new_empty(data_type),
35 }
36 }
37}