## 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/functions/src/core/planner.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::Field;
    19
    use datafusion_common::Result;
    20
    use datafusion_common::{Column, DFSchema, ScalarValue, TableReference};
    21
    use datafusion_expr::expr::ScalarFunction;
    22
    use datafusion_expr::planner::{ExprPlanner, PlannerResult, RawDictionaryExpr};
    23
    use datafusion_expr::{lit, Expr};
    24
    25
    use super::named_struct;
    26
    27
    #[derive(Default, Debug)]
    28
    pub struct CoreFunctionPlanner {}
    29
    30
    impl ExprPlanner for CoreFunctionPlanner {
    31
    0
        fn plan_dictionary_literal(
    32
    0
            &self,
    33
    0
            expr: RawDictionaryExpr,
    34
    0
            _schema: &DFSchema,
    35
    0
        ) -> Result<PlannerResult<RawDictionaryExpr>> {
    36
    0
            let mut args = vec![];
    37
    0
            for (k, v) in expr.keys.into_iter().zip(expr.values.into_iter()) {
    38
    0
                args.push(k);
    39
    0
                args.push(v);
    40
    0
            }
    41
    0
            Ok(PlannerResult::Planned(named_struct().call(args)))
    42
    0
        }
    43
    44
    0
        fn plan_struct_literal(
    45
    0
            &self,
    46
    0
            args: Vec<Expr>,
    47
    0
            is_named_struct: bool,
    48
    0
        ) -> Result<PlannerResult<Vec<Expr>>> {
    49
            Ok(PlannerResult::Planned(Expr::ScalarFunction(
    50
    0
                ScalarFunction::new_udf(
    51
    0
                    if is_named_struct {
    52
    0
                        named_struct()
    53
                    } else {
    54
    0
                        crate::core::r#struct()
    55
                    },
    56
    0
                    args,
    57
                ),
    58
            )))
    59
    0
        }
    60
    61
    0
        fn plan_overlay(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> {
    62
    0
            Ok(PlannerResult::Planned(Expr::ScalarFunction(
    63
    0
                ScalarFunction::new_udf(crate::core::overlay(), args),
    64
    0
            )))
    65
    0
        }
    66
    67
    0
        fn plan_compound_identifier(
    68
    0
            &self,
    69
    0
            field: &Field,
    70
    0
            qualifier: Option<&TableReference>,
    71
    0
            nested_names: &[String],
    72
    0
        ) -> Result<PlannerResult<Vec<Expr>>> {
    73
    0
            let col = Expr::Column(Column::from((qualifier, field)));
    74
    75
            // Start with the base column expression
    76
    0
            let mut expr = col;
    77
    78
            // Iterate over nested_names and create nested get_field expressions
    79
    0
            for nested_name in nested_names {
    80
    0
                let get_field_args = vec![expr, lit(ScalarValue::from(nested_name.clone()))];
    81
    0
                expr = Expr::ScalarFunction(ScalarFunction::new_udf(
    82
    0
                    crate::core::get_field(),
    83
    0
                    get_field_args,
    84
    0
                ));
    85
    0
            }
    86
    87
    0
            Ok(PlannerResult::Planned(expr))
    88
    0
        }
    89
    }