proof_of_sql/base/database/
column_field.rs

1use super::ColumnType;
2use serde::{Deserialize, Serialize};
3use sqlparser::ast::Ident;
4
5/// This type is used to represent the metadata
6/// of a column in a table. Namely: it's name and type.
7///
8/// This is the analog of a `Field` in Apache Arrow.
9#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
10pub struct ColumnField {
11    name: Ident,
12    data_type: ColumnType,
13}
14
15impl ColumnField {
16    /// Create a new `ColumnField` from a name and a type
17    #[must_use]
18    pub fn new(name: Ident, data_type: ColumnType) -> ColumnField {
19        ColumnField { name, data_type }
20    }
21
22    /// Returns the name of the column
23    #[must_use]
24    pub fn name(&self) -> Ident {
25        self.name.clone()
26    }
27
28    /// Returns the type of the column
29    #[must_use]
30    pub fn data_type(&self) -> ColumnType {
31        self.data_type
32    }
33}