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