## 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/common/src/types/builtin.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
    use arrow::datatypes::IntervalUnit::*;
    19
    20
    use crate::types::{LogicalTypeRef, NativeType};
    21
    use std::sync::{Arc, LazyLock};
    22
    23
    /// Create a singleton and accompanying static variable for a [`LogicalTypeRef`]
    24
    /// of a [`NativeType`].
    25
    /// * `name`: name of the static variable, must be unique.
    26
    /// * `getter`: name of the public function that will return the singleton instance
    27
    ///   of the static variable.
    28
    /// * `ty`: the [`NativeType`].
    29
    macro_rules! singleton {
    30
        ($name:ident, $getter:ident, $ty:ident) => {
    31
            static $name: LazyLock<LogicalTypeRef> =
    32
    0
                LazyLock::new(|| Arc::new(NativeType::$ty));
    33
    34
            #[doc = "Getter for singleton instance of a logical type representing"]
    35
            #[doc = concat!("[`NativeType::", stringify!($ty), "`].")]
    36
    0
            pub fn $getter() -> LogicalTypeRef {
    37
    0
                Arc::clone(&$name)
    38
    0
            }
    39
        };
    40
    }
    41
    42
    /// Similar to [`singleton`], but for native types that have variants, such as
    43
    /// `NativeType::Interval(MonthDayNano)`.
    44
    /// * `name`: name of the static variable, must be unique.
    45
    /// * `getter`: name of the public function that will return the singleton instance
    46
    ///   of the static variable.
    47
    /// * `ty`: the [`NativeType`].
    48
    /// * `variant`: specific variant of the `ty`.
    49
    macro_rules! singleton_variant {
    50
        ($name:ident, $getter:ident, $ty:ident, $variant:ident) => {
    51
            static $name: LazyLock<LogicalTypeRef> =
    52
    0
                LazyLock::new(|| Arc::new(NativeType::$ty($variant)));
    53
    54
            #[doc = "Getter for singleton instance of a logical type representing"]
    55
            #[doc = concat!("[`NativeType::", stringify!($ty), "`] of unit [`", stringify!($variant),"`].`")]
    56
    0
            pub fn $getter() -> LogicalTypeRef {
    57
    0
                Arc::clone(&$name)
    58
    0
            }
    59
        };
    60
    }
    61
    62
    singleton!(LOGICAL_NULL, logical_null, Null);
    63
    singleton!(LOGICAL_BOOLEAN, logical_boolean, Boolean);
    64
    singleton!(LOGICAL_INT8, logical_int8, Int8);
    65
    singleton!(LOGICAL_INT16, logical_int16, Int16);
    66
    singleton!(LOGICAL_INT32, logical_int32, Int32);
    67
    singleton!(LOGICAL_INT64, logical_int64, Int64);
    68
    singleton!(LOGICAL_UINT8, logical_uint8, UInt8);
    69
    singleton!(LOGICAL_UINT16, logical_uint16, UInt16);
    70
    singleton!(LOGICAL_UINT32, logical_uint32, UInt32);
    71
    singleton!(LOGICAL_UINT64, logical_uint64, UInt64);
    72
    singleton!(LOGICAL_FLOAT16, logical_float16, Float16);
    73
    singleton!(LOGICAL_FLOAT32, logical_float32, Float32);
    74
    singleton!(LOGICAL_FLOAT64, logical_float64, Float64);
    75
    singleton!(LOGICAL_DATE, logical_date, Date);
    76
    singleton!(LOGICAL_BINARY, logical_binary, Binary);
    77
    singleton!(LOGICAL_STRING, logical_string, String);
    78
    79
    singleton_variant!(
    80
        LOGICAL_INTERVAL_MDN,
    81
        logical_interval_mdn,
    82
        Interval,
    83
        MonthDayNano
    84
    );