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