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