## 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/unknown_column.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
    //! UnKnownColumn expression
    19
    20
    use std::any::Any;
    21
    use std::hash::{Hash, Hasher};
    22
    use std::sync::Arc;
    23
    24
    use crate::PhysicalExpr;
    25
    26
    use arrow::{
    27
        datatypes::{DataType, Schema},
    28
        record_batch::RecordBatch,
    29
    };
    30
    use datafusion_common::{internal_err, Result};
    31
    use datafusion_expr::ColumnarValue;
    32
    33
    #[derive(Debug, Clone, Eq)]
    34
    pub struct UnKnownColumn {
    35
        name: String,
    36
    }
    37
    38
    impl UnKnownColumn {
    39
        /// Create a new unknown column expression
    40
    0
        pub fn new(name: &str) -> Self {
    41
    0
            Self {
    42
    0
                name: name.to_owned(),
    43
    0
            }
    44
    0
        }
    45
    46
        /// Get the column name
    47
    0
        pub fn name(&self) -> &str {
    48
    0
            &self.name
    49
    0
        }
    50
    }
    51
    52
    impl std::fmt::Display for UnKnownColumn {
    53
    0
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    54
    0
            write!(f, "{}", self.name)
    55
    0
        }
    56
    }
    57
    58
    impl PhysicalExpr for UnKnownColumn {
    59
        /// Return a reference to Any that can be used for downcasting
    60
    0
        fn as_any(&self) -> &dyn Any {
    61
    0
            self
    62
    0
        }
    63
    64
        /// Get the data type of this expression, given the schema of the input
    65
    0
        fn data_type(&self, _input_schema: &Schema) -> Result<DataType> {
    66
    0
            Ok(DataType::Null)
    67
    0
        }
    68
    69
        /// Decide whether this expression is nullable, given the schema of the input
    70
    0
        fn nullable(&self, _input_schema: &Schema) -> Result<bool> {
    71
    0
            Ok(true)
    72
    0
        }
    73
    74
        /// Evaluate the expression
    75
    0
        fn evaluate(&self, _batch: &RecordBatch) -> Result<ColumnarValue> {
    76
    0
            internal_err!("UnKnownColumn::evaluate() should not be called")
    77
    0
        }
    78
    79
    0
        fn children(&self) -> Vec<&Arc<dyn PhysicalExpr>> {
    80
    0
            vec![]
    81
    0
        }
    82
    83
    0
        fn with_new_children(
    84
    0
            self: Arc<Self>,
    85
    0
            _children: Vec<Arc<dyn PhysicalExpr>>,
    86
    0
        ) -> Result<Arc<dyn PhysicalExpr>> {
    87
    0
            Ok(self)
    88
    0
        }
    89
    90
    0
        fn fmt_sql(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    91
    0
            std::fmt::Display::fmt(self, f)
    92
    0
        }
    93
    }
    94
    95
    impl Hash for UnKnownColumn {
    96
    0
        fn hash<H: Hasher>(&self, state: &mut H) {
    97
    0
            self.name.hash(state);
    98
    0
        }
    99
    }
    100
    101
    impl PartialEq for UnKnownColumn {
    102
    0
        fn eq(&self, _other: &Self) -> bool {
    103
            // UnknownColumn is not a valid expression, so it should not be equal to any other expression.
    104
            // See https://github.com/apache/datafusion/pull/11536
    105
    0
            false
    106
    0
        }
    107
    }