## 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/expr/src/type_coercion/mod.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
    //! Type coercion rules for DataFusion
    19
    //!
    20
    //! Coercion is performed automatically by DataFusion when the types
    21
    //! of arguments passed to a function or needed by operators do not
    22
    //! exactly match the types required by that function / operator. In
    23
    //! this case, DataFusion will attempt to *coerce* the arguments to
    24
    //! types accepted by the function by inserting CAST operations.
    25
    //!
    26
    //! CAST operations added by coercion are lossless and never discard
    27
    //! information.
    28
    //!
    29
    //! For example coercion from i32 -> i64 might be
    30
    //! performed because all valid i32 values can be represented using an
    31
    //! i64. However, i64 -> i32 is never performed as there are i64
    32
    //! values which can not be represented by i32 values.
    33
    34
    pub mod aggregates {
    35
        pub use datafusion_expr_common::type_coercion::aggregates::*;
    36
    }
    37
    pub mod functions;
    38
    pub mod other;
    39
    40
    pub use datafusion_expr_common::type_coercion::binary;
    41
    42
    use arrow::datatypes::DataType;
    43
    /// Determine whether the given data type `dt` represents signed numeric values.
    44
    0
    pub fn is_signed_numeric(dt: &DataType) -> bool {
    45
    0
        matches!(
    46
    0
            dt,
    47
            DataType::Int8
    48
                | DataType::Int16
    49
                | DataType::Int32
    50
                | DataType::Int64
    51
                | DataType::Float16
    52
                | DataType::Float32
    53
                | DataType::Float64
    54
                | DataType::Decimal32(_, _)
    55
                | DataType::Decimal64(_, _)
    56
                | DataType::Decimal128(_, _)
    57
                | DataType::Decimal256(_, _),
    58
        )
    59
    0
    }
    60
    61
    /// Determine whether the given data type `dt` is `Null`.
    62
    0
    pub fn is_null(dt: &DataType) -> bool {
    63
    0
        *dt == DataType::Null
    64
    0
    }
    65
    66
    /// Determine whether the given data type `dt` is a `Timestamp`.
    67
    0
    pub fn is_timestamp(dt: &DataType) -> bool {
    68
    0
        matches!(dt, DataType::Timestamp(_, _))
    69
    0
    }
    70
    71
    /// Determine whether the given data type 'dt' is a `Interval`.
    72
    0
    pub fn is_interval(dt: &DataType) -> bool {
    73
    0
        matches!(dt, DataType::Interval(_))
    74
    0
    }
    75
    76
    /// Determine whether the given data type `dt` is a `Date` or `Timestamp`.
    77
    0
    pub fn is_datetime(dt: &DataType) -> bool {
    78
    0
        matches!(
    79
    0
            dt,
    80
            DataType::Date32 | DataType::Date64 | DataType::Timestamp(_, _)
    81
        )
    82
    0
    }
    83
    84
    /// Determine whether the given data type `dt` is a `Utf8` or `Utf8View` or `LargeUtf8`.
    85
    0
    pub fn is_utf8_or_utf8view_or_large_utf8(dt: &DataType) -> bool {
    86
    0
        matches!(
    87
    0
            dt,
    88
            DataType::Utf8 | DataType::Utf8View | DataType::LargeUtf8
    89
        )
    90
    0
    }
    91
    92
    /// Determine whether the given data type `dt` is a `Decimal`.
    93
    0
    pub fn is_decimal(dt: &DataType) -> bool {
    94
    0
        matches!(
    95
    0
            dt,
    96
            DataType::Decimal32(_, _)
    97
                | DataType::Decimal64(_, _)
    98
                | DataType::Decimal128(_, _)
    99
                | DataType::Decimal256(_, _)
    100
        )
    101
    0
    }