datafusion_functions_window_common/
expr.rs

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
18use datafusion_common::arrow::datatypes::DataType;
19use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
20use std::sync::Arc;
21
22/// Arguments passed to user-defined window function
23#[derive(Debug, Default)]
24pub struct ExpressionArgs<'a> {
25    /// The expressions passed as arguments to the user-defined window
26    /// function.
27    input_exprs: &'a [Arc<dyn PhysicalExpr>],
28    /// The corresponding data types of expressions passed as arguments
29    /// to the user-defined window function.
30    input_types: &'a [DataType],
31}
32
33impl<'a> ExpressionArgs<'a> {
34    /// Create an instance of [`ExpressionArgs`].
35    ///
36    /// # Arguments
37    ///
38    /// * `input_exprs` - The expressions passed as arguments
39    ///     to the user-defined window function.
40    /// * `input_types` - The data types corresponding to the
41    ///     arguments to the user-defined window function.
42    ///
43    pub fn new(
44        input_exprs: &'a [Arc<dyn PhysicalExpr>],
45        input_types: &'a [DataType],
46    ) -> Self {
47        Self {
48            input_exprs,
49            input_types,
50        }
51    }
52
53    /// Returns the expressions passed as arguments to the user-defined
54    /// window function.
55    pub fn input_exprs(&self) -> &'a [Arc<dyn PhysicalExpr>] {
56        self.input_exprs
57    }
58
59    /// Returns the [`DataType`]s corresponding to the input expressions
60    /// to the user-defined window function.
61    pub fn input_types(&self) -> &'a [DataType] {
62        self.input_types
63    }
64}