/Users/andrewlamb/Software/datafusion/datafusion/functions-window-common/src/field.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 | | |
18 | | use datafusion_common::arrow::datatypes::DataType; |
19 | | |
20 | | /// Metadata for defining the result field from evaluating a |
21 | | /// user-defined window function. |
22 | | pub struct WindowUDFFieldArgs<'a> { |
23 | | /// The data types corresponding to the arguments to the |
24 | | /// user-defined window function. |
25 | | input_types: &'a [DataType], |
26 | | /// The display name of the user-defined window function. |
27 | | display_name: &'a str, |
28 | | } |
29 | | |
30 | | impl<'a> WindowUDFFieldArgs<'a> { |
31 | | /// Create an instance of [`WindowUDFFieldArgs`]. |
32 | | /// |
33 | | /// # Arguments |
34 | | /// |
35 | | /// * `input_types` - The data types corresponding to the |
36 | | /// arguments to the user-defined window function. |
37 | | /// * `function_name` - The qualified schema name of the |
38 | | /// user-defined window function expression. |
39 | | /// |
40 | 0 | pub fn new(input_types: &'a [DataType], display_name: &'a str) -> Self { |
41 | 0 | WindowUDFFieldArgs { |
42 | 0 | input_types, |
43 | 0 | display_name, |
44 | 0 | } |
45 | 0 | } |
46 | | |
47 | | /// Returns the data type of input expressions passed as arguments |
48 | | /// to the user-defined window function. |
49 | 0 | pub fn input_types(&self) -> &[DataType] { |
50 | 0 | self.input_types |
51 | 0 | } |
52 | | |
53 | | /// Returns the name for the field of the final result of evaluating |
54 | | /// the user-defined window function. |
55 | 0 | pub fn name(&self) -> &str { |
56 | 0 | self.display_name |
57 | 0 | } |
58 | | |
59 | | /// Returns `Some(DataType)` of input expression at index, otherwise |
60 | | /// returns `None` if the index is out of bounds. |
61 | 0 | pub fn get_input_type(&self, index: usize) -> Option<DataType> { |
62 | 0 | self.input_types.get(index).cloned() |
63 | 0 | } |
64 | | } |