datafusion_physical_expr/expressions/
unknown_column.rs1use std::hash::{Hash, Hasher};
21use std::sync::Arc;
22
23use crate::PhysicalExpr;
24
25use arrow::{
26 datatypes::{DataType, Schema},
27 record_batch::RecordBatch,
28};
29use datafusion_common::{Result, internal_err};
30use datafusion_expr::ColumnarValue;
31
32#[derive(Debug, Clone, Eq)]
33pub struct UnKnownColumn {
34 name: String,
35}
36
37impl UnKnownColumn {
38 pub fn new(name: &str) -> Self {
40 Self {
41 name: name.to_owned(),
42 }
43 }
44
45 pub fn name(&self) -> &str {
47 &self.name
48 }
49}
50
51impl std::fmt::Display for UnKnownColumn {
52 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
53 write!(f, "{}", self.name)
54 }
55}
56
57impl PhysicalExpr for UnKnownColumn {
58 fn data_type(&self, _input_schema: &Schema) -> Result<DataType> {
60 Ok(DataType::Null)
61 }
62
63 fn nullable(&self, _input_schema: &Schema) -> Result<bool> {
65 Ok(true)
66 }
67
68 fn evaluate(&self, _batch: &RecordBatch) -> Result<ColumnarValue> {
70 internal_err!("UnKnownColumn::evaluate() should not be called")
71 }
72
73 fn children(&self) -> Vec<&Arc<dyn PhysicalExpr>> {
74 vec![]
75 }
76
77 fn with_new_children(
78 self: Arc<Self>,
79 _children: Vec<Arc<dyn PhysicalExpr>>,
80 ) -> Result<Arc<dyn PhysicalExpr>> {
81 Ok(self)
82 }
83
84 fn fmt_sql(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
85 std::fmt::Display::fmt(self, f)
86 }
87}
88
89impl Hash for UnKnownColumn {
90 fn hash<H: Hasher>(&self, state: &mut H) {
91 self.name.hash(state);
92 }
93}
94
95impl PartialEq for UnKnownColumn {
96 fn eq(&self, _other: &Self) -> bool {
97 false
100 }
101}