reifydb_core/interface/evaluate/
mod.rs1use reifydb_value::{error::NumberOutOfRangeDescriptor, value::value_type::ValueType};
5
6use crate::interface::{
7 catalog::property::ColumnPropertyKind,
8 resolved::{ResolvedColumn, resolved_column_to_number_descriptor},
9};
10
11#[derive(Debug, Clone)]
12pub enum TargetColumn {
13 Resolved(ResolvedColumn),
14
15 Partial {
16 source_name: Option<String>,
17 column_name: Option<String>,
18 column_type: ValueType,
19 properties: Vec<ColumnPropertyKind>,
20 },
21}
22
23impl TargetColumn {
24 pub fn column_type(&self) -> ValueType {
25 match self {
26 Self::Resolved(col) => col.column_type(),
27 Self::Partial {
28 column_type,
29 ..
30 } => column_type.clone(),
31 }
32 }
33
34 pub fn properties(&self) -> Vec<ColumnPropertyKind> {
35 match self {
36 Self::Resolved(col) => col.properties(),
37 Self::Partial {
38 properties,
39 ..
40 } => properties.clone(),
41 }
42 }
43
44 pub fn to_number_descriptor(&self) -> Option<NumberOutOfRangeDescriptor> {
45 match self {
46 Self::Resolved(col) => Some(resolved_column_to_number_descriptor(col)),
47 Self::Partial {
48 column_type,
49 source_name,
50 column_name,
51 ..
52 } => {
53 if source_name.is_some() || column_name.is_some() {
54 Some(NumberOutOfRangeDescriptor {
55 namespace: None,
56 table: source_name.clone(),
57 column: column_name.clone(),
58 column_type: Some(column_type.clone()),
59 })
60 } else {
61 None
62 }
63 }
64 }
65 }
66}