## Coverage Report

#### Created: 2025-11-22 06:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /Users/andrewlamb/Software/datafusion/datafusion/physical-expr/src/expressions/no_op.rs

    Line
    Count
    Source
    1
    // Licensed to the Apache Software Foundation (ASF) under one
    2
    // or more contributor license agreements.  See the NOTICE file
    3
    // distributed with this work for additional information
    4
    // regarding copyright ownership.  The ASF licenses this file
    5
    // to you under the Apache License, Version 2.0 (the
    6
    // "License"); you may not use this file except in compliance
    7
    // with the License.  You may obtain a copy of the License at
    8
    //
    9
    //   http://www.apache.org/licenses/LICENSE-2.0
    10
    //
    11
    // Unless required by applicable law or agreed to in writing,
    12
    // software distributed under the License is distributed on an
    13
    // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    14
    // KIND, either express or implied.  See the License for the
    15
    // specific language governing permissions and limitations
    16
    // under the License.
    17
    18
    //! NoOp placeholder for physical operations
    19
    20
    use std::any::Any;
    21
    use std::hash::Hash;
    22
    use std::sync::Arc;
    23
    24
    use crate::PhysicalExpr;
    25
    use arrow::{
    26
        datatypes::{DataType, Schema},
    27
        record_batch::RecordBatch,
    28
    };
    29
    use datafusion_common::{internal_err, Result};
    30
    use datafusion_expr::ColumnarValue;
    31
    32
    /// A place holder expression, can not be evaluated.
    33
    ///
    34
    /// Used in some cases where an `Arc<dyn PhysicalExpr>` is needed, such as `children()`
    35
    #[derive(Debug, PartialEq, Eq, Default, Hash)]
    36
    pub struct NoOp {}
    37
    38
    impl NoOp {
    39
        /// Create a NoOp expression
    40
    0
        pub fn new() -> Self {
    41
    0
            Self {}
    42
    0
        }
    43
    }
    44
    45
    impl std::fmt::Display for NoOp {
    46
    0
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    47
    0
            write!(f, "NoOp")
    48
    0
        }
    49
    }
    50
    51
    impl PhysicalExpr for NoOp {
    52
        /// Return a reference to Any that can be used for downcasting
    53
    0
        fn as_any(&self) -> &dyn Any {
    54
    0
            self
    55
    0
        }
    56
    57
    0
        fn data_type(&self, _input_schema: &Schema) -> Result<DataType> {
    58
    0
            Ok(DataType::Null)
    59
    0
        }
    60
    61
    0
        fn nullable(&self, _input_schema: &Schema) -> Result<bool> {
    62
    0
            Ok(true)
    63
    0
        }
    64
    65
    0
        fn evaluate(&self, _batch: &RecordBatch) -> Result<ColumnarValue> {
    66
    0
            internal_err!("NoOp::evaluate() should not be called")
    67
    0
        }
    68
    69
    0
        fn children(&self) -> Vec<&Arc<dyn PhysicalExpr>> {
    70
    0
            vec![]
    71
    0
        }
    72
    73
    0
        fn with_new_children(
    74
    0
            self: Arc<Self>,
    75
    0
            _children: Vec<Arc<dyn PhysicalExpr>>,
    76
    0
        ) -> Result<Arc<dyn PhysicalExpr>> {
    77
    0
            Ok(self)
    78
    0
        }
    79
    80
    0
        fn fmt_sql(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    81
    0
            std::fmt::Display::fmt(self, f)
    82
    0
        }
    83
    }