reifydb_core/interface/evaluate/
mod.rs1use reifydb_type::{error::diagnostic::number::NumberOfRangeColumnDescriptor, value::r#type::Type};
5
6use crate::interface::{
7 catalog::policy::ColumnPolicyKind,
8 resolved::{ResolvedColumn, resolved_column_to_number_descriptor},
9};
10
11#[derive(Debug, Clone)]
13pub enum TargetColumn {
14 Resolved(ResolvedColumn),
16 Partial {
18 source_name: Option<String>,
19 column_name: Option<String>,
20 column_type: Type,
21 policies: Vec<ColumnPolicyKind>,
22 },
23}
24
25impl TargetColumn {
26 pub fn column_type(&self) -> Type {
28 match self {
29 Self::Resolved(col) => col.column_type(),
30 Self::Partial {
31 column_type,
32 ..
33 } => column_type.clone(),
34 }
35 }
36
37 pub fn policies(&self) -> Vec<ColumnPolicyKind> {
39 match self {
40 Self::Resolved(col) => col.policies(),
41 Self::Partial {
42 policies,
43 ..
44 } => policies.clone(),
45 }
46 }
47
48 pub fn to_number_descriptor(&self) -> Option<NumberOfRangeColumnDescriptor<'_>> {
50 match self {
51 Self::Resolved(col) => Some(resolved_column_to_number_descriptor(col)),
52 Self::Partial {
53 column_type,
54 source_name,
55 column_name,
56 ..
57 } => {
58 if source_name.is_some() || column_name.is_some() {
60 Some(NumberOfRangeColumnDescriptor {
61 namespace: None,
62 table: source_name.as_deref(),
63 column: column_name.as_deref(),
64 column_type: Some(column_type.clone()),
65 })
66 } else {
67 None
68 }
69 }
70 }
71 }
72}