Skip to main content

datafusion_doc/
udf.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
3// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
4
5// Scalar UDF doc sections for use in public documentation
6pub mod scalar_doc_sections {
7    use crate::DocSection;
8
9    pub fn doc_sections() -> Vec<DocSection> {
10        vec![
11            DOC_SECTION_MATH,
12            DOC_SECTION_CONDITIONAL,
13            DOC_SECTION_STRING,
14            DOC_SECTION_BINARY_STRING,
15            DOC_SECTION_REGEX,
16            DOC_SECTION_DATETIME,
17            DOC_SECTION_ARRAY,
18            DOC_SECTION_STRUCT,
19            DOC_SECTION_MAP,
20            DOC_SECTION_HASHING,
21            DOC_SECTION_UNION,
22            DOC_SECTION_OTHER,
23        ]
24    }
25
26    pub const fn doc_sections_const() -> &'static [DocSection] {
27        &[
28            DOC_SECTION_MATH,
29            DOC_SECTION_CONDITIONAL,
30            DOC_SECTION_STRING,
31            DOC_SECTION_BINARY_STRING,
32            DOC_SECTION_REGEX,
33            DOC_SECTION_DATETIME,
34            DOC_SECTION_ARRAY,
35            DOC_SECTION_STRUCT,
36            DOC_SECTION_MAP,
37            DOC_SECTION_HASHING,
38            DOC_SECTION_UNION,
39            DOC_SECTION_OTHER,
40        ]
41    }
42
43    pub const DOC_SECTION_MATH: DocSection = DocSection {
44        include: true,
45        label: "Math Functions",
46        description: None,
47    };
48
49    pub const DOC_SECTION_CONDITIONAL: DocSection = DocSection {
50        include: true,
51        label: "Conditional Functions",
52        description: None,
53    };
54
55    pub const DOC_SECTION_STRING: DocSection = DocSection {
56        include: true,
57        label: "String Functions",
58        description: None,
59    };
60
61    pub const DOC_SECTION_BINARY_STRING: DocSection = DocSection {
62        include: true,
63        label: "Binary String Functions",
64        description: None,
65    };
66
67    pub const DOC_SECTION_REGEX: DocSection = DocSection {
68        include: true,
69        label: "Regular Expression Functions",
70        description: Some(
71            r#"Apache DataFusion uses a [PCRE-like](https://en.wikibooks.org/wiki/Regular_Expressions/Perl-Compatible_Regular_Expressions)
72regular expression [syntax](https://docs.rs/regex/latest/regex/#syntax)
73(minus support for several features including look-around and backreferences).
74
75The following flags are optionally supported in functions:
76  - **i**: case-insensitive: letters match both upper and lower case
77  - **m**: multi-line mode: `^` and `$` match begin/end of line
78  - **s**: allow `.` to match `\n`
79  - **R**: enables CRLF mode: when multi-line mode is enabled, `\r\n` is used
80  - **U**: swap the meaning of `x*` and `x*?`
81
82The following regular expression functions are supported:"#,
83        ),
84    };
85
86    pub const DOC_SECTION_DATETIME: DocSection = DocSection {
87        include: true,
88        label: "Time and Date Functions",
89        description: None,
90    };
91
92    pub const DOC_SECTION_ARRAY: DocSection = DocSection {
93        include: true,
94        label: "Array Functions",
95        description: None,
96    };
97
98    pub const DOC_SECTION_STRUCT: DocSection = DocSection {
99        include: true,
100        label: "Struct Functions",
101        description: None,
102    };
103
104    pub const DOC_SECTION_MAP: DocSection = DocSection {
105        include: true,
106        label: "Map Functions",
107        description: None,
108    };
109
110    pub const DOC_SECTION_HASHING: DocSection = DocSection {
111        include: true,
112        label: "Hashing Functions",
113        description: None,
114    };
115
116    pub const DOC_SECTION_OTHER: DocSection = DocSection {
117        include: true,
118        label: "Other Functions",
119        description: None,
120    };
121
122    pub const DOC_SECTION_UNION: DocSection = DocSection {
123        include: true,
124        label: "Union Functions",
125        description: Some(
126            "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",
127        ),
128    };
129}