## 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/intervals/test_utils.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
    //! Test utilities for the interval arithmetic library
    19
    20
    use std::sync::Arc;
    21
    22
    use crate::expressions::{binary, BinaryExpr, Literal};
    23
    use crate::PhysicalExpr;
    24
    use arrow::datatypes::Schema;
    25
    use datafusion_common::{DataFusionError, ScalarValue};
    26
    use datafusion_expr::Operator;
    27
    28
    #[allow(clippy::too_many_arguments)]
    29
    /// This test function generates a conjunctive statement with two numeric
    30
    /// terms with the following form:
    31
    /// left_col (op_1) a  >/>= right_col (op_2) b AND left_col (op_3) c </<= right_col (op_4) d
    32
    0
    pub fn gen_conjunctive_numerical_expr(
    33
    0
        left_col: Arc<dyn PhysicalExpr>,
    34
    0
        right_col: Arc<dyn PhysicalExpr>,
    35
    0
        op: (Operator, Operator, Operator, Operator),
    36
    0
        a: ScalarValue,
    37
    0
        b: ScalarValue,
    38
    0
        c: ScalarValue,
    39
    0
        d: ScalarValue,
    40
    0
        bounds: (Operator, Operator),
    41
    0
    ) -> Arc<dyn PhysicalExpr> {
    42
    0
        let (op_1, op_2, op_3, op_4) = op;
    43
    0
        let left_and_1 = Arc::new(BinaryExpr::new(
    44
    0
            Arc::clone(&left_col),
    45
    0
            op_1,
    46
    0
            Arc::new(Literal::new(a)),
    47
        ));
    48
    0
        let left_and_2 = Arc::new(BinaryExpr::new(
    49
    0
            Arc::clone(&right_col),
    50
    0
            op_2,
    51
    0
            Arc::new(Literal::new(b)),
    52
        ));
    53
    0
        let right_and_1 =
    54
    0
            Arc::new(BinaryExpr::new(left_col, op_3, Arc::new(Literal::new(c))));
    55
    0
        let right_and_2 =
    56
    0
            Arc::new(BinaryExpr::new(right_col, op_4, Arc::new(Literal::new(d))));
    57
    0
        let (greater_op, less_op) = bounds;
    58
    59
    0
        let left_expr = Arc::new(BinaryExpr::new(left_and_1, greater_op, left_and_2));
    60
    0
        let right_expr = Arc::new(BinaryExpr::new(right_and_1, less_op, right_and_2));
    61
    0
        Arc::new(BinaryExpr::new(left_expr, Operator::And, right_expr))
    62
    0
    }
    63
    64
    #[allow(clippy::too_many_arguments)]
    65
    /// This test function generates a conjunctive statement with
    66
    /// two scalar values with the following form:
    67
    /// left_col (op_1) a  > right_col (op_2) b AND left_col (op_3) c < right_col (op_4) d
    68
    0
    pub fn gen_conjunctive_temporal_expr(
    69
    0
        left_col: Arc<dyn PhysicalExpr>,
    70
    0
        right_col: Arc<dyn PhysicalExpr>,
    71
    0
        op_1: Operator,
    72
    0
        op_2: Operator,
    73
    0
        op_3: Operator,
    74
    0
        op_4: Operator,
    75
    0
        a: ScalarValue,
    76
    0
        b: ScalarValue,
    77
    0
        c: ScalarValue,
    78
    0
        d: ScalarValue,
    79
    0
        schema: &Schema,
    80
    0
    ) -> Result<Arc<dyn PhysicalExpr>, DataFusionError> {
    81
    0
        let left_and_1 = binary(
    82
    0
            Arc::clone(&left_col),
    83
    0
            op_1,
    84
    0
            Arc::new(Literal::new(a)),
    85
    0
            schema,
    86
    0
        )?;
    87
    0
        let left_and_2 = binary(
    88
    0
            Arc::clone(&right_col),
    89
    0
            op_2,
    90
    0
            Arc::new(Literal::new(b)),
    91
    0
            schema,
    92
    0
        )?;
    93
    0
        let right_and_1 = binary(left_col, op_3, Arc::new(Literal::new(c)), schema)?;
    94
    0
        let right_and_2 = binary(right_col, op_4, Arc::new(Literal::new(d)), schema)?;
    95
    0
        let left_expr = Arc::new(BinaryExpr::new(left_and_1, Operator::Gt, left_and_2));
    96
    0
        let right_expr = Arc::new(BinaryExpr::new(right_and_1, Operator::Lt, right_and_2));
    97
    0
        Ok(Arc::new(BinaryExpr::new(
    98
    0
            left_expr,
    99
    0
            Operator::And,
    100
    0
            right_expr,
    101
    0
        )))
    102
    0
    }