Skip to main content

datafusion_doc/
udf.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
18// Scalar UDF doc sections for use in public documentation
19pub mod scalar_doc_sections {
20    use crate::DocSection;
21
22    pub fn doc_sections() -> Vec<DocSection> {
23        vec![
24            DOC_SECTION_MATH,
25            DOC_SECTION_CONDITIONAL,
26            DOC_SECTION_STRING,
27            DOC_SECTION_BINARY_STRING,
28            DOC_SECTION_REGEX,
29            DOC_SECTION_DATETIME,
30            DOC_SECTION_ARRAY,
31            DOC_SECTION_STRUCT,
32            DOC_SECTION_MAP,
33            DOC_SECTION_HASHING,
34            DOC_SECTION_UNION,
35            DOC_SECTION_OTHER,
36        ]
37    }
38
39    pub const fn doc_sections_const() -> &'static [DocSection] {
40        &[
41            DOC_SECTION_MATH,
42            DOC_SECTION_CONDITIONAL,
43            DOC_SECTION_STRING,
44            DOC_SECTION_BINARY_STRING,
45            DOC_SECTION_REGEX,
46            DOC_SECTION_DATETIME,
47            DOC_SECTION_ARRAY,
48            DOC_SECTION_STRUCT,
49            DOC_SECTION_MAP,
50            DOC_SECTION_HASHING,
51            DOC_SECTION_UNION,
52            DOC_SECTION_OTHER,
53        ]
54    }
55
56    pub const DOC_SECTION_MATH: DocSection = DocSection {
57        include: true,
58        label: "Math Functions",
59        description: None,
60    };
61
62    pub const DOC_SECTION_CONDITIONAL: DocSection = DocSection {
63        include: true,
64        label: "Conditional Functions",
65        description: None,
66    };
67
68    pub const DOC_SECTION_STRING: DocSection = DocSection {
69        include: true,
70        label: "String Functions",
71        description: None,
72    };
73
74    pub const DOC_SECTION_BINARY_STRING: DocSection = DocSection {
75        include: true,
76        label: "Binary String Functions",
77        description: None,
78    };
79
80    pub const DOC_SECTION_REGEX: DocSection = DocSection {
81        include: true,
82        label: "Regular Expression Functions",
83        description: Some(
84            r#"Apache DataFusion uses a [PCRE-like](https://en.wikibooks.org/wiki/Regular_Expressions/Perl-Compatible_Regular_Expressions)
85regular expression [syntax](https://docs.rs/regex/latest/regex/#syntax)
86(minus support for several features including look-around and backreferences).
87
88The following flags are optionally supported in functions:
89  - **i**: case-insensitive: letters match both upper and lower case
90  - **m**: multi-line mode: `^` and `$` match begin/end of line
91  - **s**: allow `.` to match `\n`
92  - **R**: enables CRLF mode: when multi-line mode is enabled, `\r\n` is used
93  - **U**: swap the meaning of `x*` and `x*?`
94
95The following regular expression functions are supported:"#,
96        ),
97    };
98
99    pub const DOC_SECTION_DATETIME: DocSection = DocSection {
100        include: true,
101        label: "Time and Date Functions",
102        description: None,
103    };
104
105    pub const DOC_SECTION_ARRAY: DocSection = DocSection {
106        include: true,
107        label: "Array Functions",
108        description: None,
109    };
110
111    pub const DOC_SECTION_STRUCT: DocSection = DocSection {
112        include: true,
113        label: "Struct Functions",
114        description: None,
115    };
116
117    pub const DOC_SECTION_MAP: DocSection = DocSection {
118        include: true,
119        label: "Map Functions",
120        description: None,
121    };
122
123    pub const DOC_SECTION_HASHING: DocSection = DocSection {
124        include: true,
125        label: "Hashing Functions",
126        description: None,
127    };
128
129    pub const DOC_SECTION_OTHER: DocSection = DocSection {
130        include: true,
131        label: "Other Functions",
132        description: None,
133    };
134
135    pub const DOC_SECTION_UNION: DocSection = DocSection {
136        include: true,
137        label: "Union Functions",
138        description: Some(
139            "Functions to work with the union data type, also know as tagged unions, variant types, enums or sum types. Note: Not related to the SQL UNION operator",
140        ),
141    };
142}