## Coverage Report

#### Created: 2024-10-13 08:39

    /Users/andrewlamb/Software/datafusion/datafusion/common/src/lib.rs

    Line
    Count
    Source (jump to first uncovered line)
    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
    // Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
    18
    #![deny(clippy::clone_on_ref_ptr)]
    19
    20
    mod column;
    21
    mod dfschema;
    22
    mod functional_dependencies;
    23
    mod join_type;
    24
    mod param_value;
    25
    #[cfg(feature = "pyarrow")]
    26
    mod pyarrow;
    27
    mod schema_reference;
    28
    mod table_reference;
    29
    mod unnest;
    30
    31
    pub mod alias;
    32
    pub mod cast;
    33
    pub mod config;
    34
    pub mod display;
    35
    pub mod error;
    36
    pub mod file_options;
    37
    pub mod format;
    38
    pub mod hash_utils;
    39
    pub mod instant;
    40
    pub mod parsers;
    41
    pub mod rounding;
    42
    pub mod scalar;
    43
    pub mod stats;
    44
    pub mod test_util;
    45
    pub mod tree_node;
    46
    pub mod utils;
    47
    48
    /// Reexport arrow crate
    49
    pub use arrow;
    50
    pub use column::Column;
    51
    pub use dfschema::{
    52
        qualified_name, DFSchema, DFSchemaRef, ExprSchema, SchemaExt, ToDFSchema,
    53
    };
    54
    pub use error::{
    55
        field_not_found, unqualified_field_not_found, DataFusionError, Result, SchemaError,
    56
        SharedResult,
    57
    };
    58
    pub use file_options::file_type::{
    59
        GetExt, DEFAULT_ARROW_EXTENSION, DEFAULT_AVRO_EXTENSION, DEFAULT_CSV_EXTENSION,
    60
        DEFAULT_JSON_EXTENSION, DEFAULT_PARQUET_EXTENSION,
    61
    };
    62
    pub use functional_dependencies::{
    63
        aggregate_functional_dependencies, get_required_group_by_exprs_indices,
    64
        get_target_functional_dependencies, Constraint, Constraints, Dependency,
    65
        FunctionalDependence, FunctionalDependencies,
    66
    };
    67
    pub use join_type::{JoinConstraint, JoinSide, JoinType};
    68
    pub use param_value::ParamValues;
    69
    pub use scalar::{ScalarType, ScalarValue};
    70
    pub use schema_reference::SchemaReference;
    71
    pub use stats::{ColumnStatistics, Statistics};
    72
    pub use table_reference::{ResolvedTableReference, TableReference};
    73
    pub use unnest::UnnestOptions;
    74
    pub use utils::project_schema;
    75
    76
    // These are hidden from docs purely to avoid polluting the public view of what this crate exports.
    77
    // These are just re-exports of macros by the same name, which gets around the 'cannot refer to
    78
    // macro-expanded macro_export macros by their full path' error.
    79
    // The design to get around this comes from this comment:
    80
    // https://github.com/rust-lang/rust/pull/52234#issuecomment-976702997
    81
    #[doc(hidden)]
    82
    pub use error::{
    83
        _config_datafusion_err, _exec_datafusion_err, _internal_datafusion_err,
    84
        _not_impl_datafusion_err, _plan_datafusion_err, _resources_datafusion_err,
    85
        _substrait_datafusion_err,
    86
    };
    87
    88
    /// Downcast an Arrow Array to a concrete type, return an `DataFusionError::Internal` if the cast is
    89
    /// not possible. In normal usage of DataFusion the downcast should always succeed.
    90
    ///
    91
    /// Example: `let array = downcast_value!(values, Int32Array)`
    92
    #[macro_export]
    93
    macro_rules! downcast_value {
    94
        ($Value: expr, $Type: ident) => {{
    95
            use std::any::type_name;
    96
    0
            $Value.as_any().downcast_ref::<$Type>().ok_or_else(|| {
    97
    0
                DataFusionError::Internal(format!(
    98
    0
                    "could not cast value to {}",
    99
    0
                    type_name::<$Type>()
    100
    0
                ))
    101
    0
            })?
    102
        }};
    103
        ($Value: expr, $Type: ident, $T: tt) => {{
    104
            use std::any::type_name;
    105
    0
            $Value.as_any().downcast_ref::<$Type<$T>>().ok_or_else(|| {
    106
    0
                DataFusionError::Internal(format!(
    107
    0
                    "could not cast value to {}",
    108
    0
                    type_name::<$Type<$T>>()
    109
    0
                ))
    110
    0
            })?
    111
        }};
    112
    }