datafusion_physical_expr/expressions/
no_op.rs1use std::hash::Hash;
21use std::sync::Arc;
22
23use crate::PhysicalExpr;
24use arrow::{
25 datatypes::{DataType, Schema},
26 record_batch::RecordBatch,
27};
28use datafusion_common::{Result, internal_err};
29use datafusion_expr::ColumnarValue;
30
31#[derive(Debug, PartialEq, Eq, Default, Hash)]
35pub struct NoOp {}
36
37impl NoOp {
38 pub fn new() -> Self {
40 Self {}
41 }
42}
43
44impl std::fmt::Display for NoOp {
45 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
46 write!(f, "NoOp")
47 }
48}
49
50impl PhysicalExpr for NoOp {
51 fn data_type(&self, _input_schema: &Schema) -> Result<DataType> {
52 Ok(DataType::Null)
53 }
54
55 fn nullable(&self, _input_schema: &Schema) -> Result<bool> {
56 Ok(true)
57 }
58
59 fn evaluate(&self, _batch: &RecordBatch) -> Result<ColumnarValue> {
60 internal_err!("NoOp::evaluate() should not be called")
61 }
62
63 fn children(&self) -> Vec<&Arc<dyn PhysicalExpr>> {
64 vec![]
65 }
66
67 fn with_new_children(
68 self: Arc<Self>,
69 _children: Vec<Arc<dyn PhysicalExpr>>,
70 ) -> Result<Arc<dyn PhysicalExpr>> {
71 Ok(self)
72 }
73
74 fn fmt_sql(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
75 std::fmt::Display::fmt(self, f)
76 }
77}