You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add DocumentationBuilder::with_standard_argument to reduce copy/paste (#12747)
* Add `DocumentationBuilder::with_standard_expression` to reduce copy/paste
* fix doc
* fix standard argument
* Update docs
* Improve documentation to explain what is different
Copy file name to clipboardExpand all lines: datafusion/expr/src/udf_docs.rs
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -131,6 +131,9 @@ impl DocumentationBuilder {
131
131
self
132
132
}
133
133
134
+
/// Adds documentation for a specific argument to the documentation.
135
+
///
136
+
/// Arguments are displayed in the order they are added.
134
137
pubfnwith_argument(
135
138
mutself,
136
139
arg_name:implInto<String>,
@@ -142,6 +145,27 @@ impl DocumentationBuilder {
142
145
self
143
146
}
144
147
148
+
/// Add a standard "expression" argument to the documentation
149
+
///
150
+
/// This is similar to [`Self::with_argument`] except that a standard
151
+
/// description is appended to the end: `"Can be a constant, column, or
152
+
/// function, and any combination of arithmetic operators."`
153
+
///
154
+
/// The argument is rendered like
155
+
///
156
+
/// ```text
157
+
/// <arg_name>:
158
+
/// <expression_type> expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
159
+
/// ```
160
+
pubfnwith_standard_argument(
161
+
self,
162
+
arg_name:implInto<String>,
163
+
expression_type:implAsRef<str>,
164
+
) -> Self{
165
+
let expression_type = expression_type.as_ref();
166
+
self.with_argument(arg_name,format!("{expression_type} expression to operate on. Can be a constant, column, or function, and any combination of operators."))
Copy file name to clipboardExpand all lines: datafusion/functions/src/datetime/to_date.rs
+1-4Lines changed: 1 addition & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -111,10 +111,7 @@ Note: `to_date` returns Date32, which represents its values as the number of day
111
111
112
112
Additional examples can be found [here](https://github.com/apache/datafusion/blob/main/datafusion-examples/examples/to_date.rs)
113
113
"#)
114
-
.with_argument(
115
-
"expression",
116
-
"Expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.",
117
-
)
114
+
.with_standard_argument("expression","String")
118
115
.with_argument(
119
116
"format_n",
120
117
"Optional [Chrono format](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) strings to use to parse the expression. Formats will be tried in the order
Copy file name to clipboardExpand all lines: docs/source/user-guide/sql/scalar_functions_new.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,8 +44,8 @@ log(numeric_expression)
44
44
45
45
#### Arguments
46
46
47
-
-**base**: Base numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
48
-
-**numeric_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
47
+
-**base**: Base numeric expression to operate on. Can be a constant, column, or function, and any combination of operators.
48
+
-**numeric_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of operators.
49
49
50
50
## Conditional Functions
51
51
@@ -94,7 +94,7 @@ rpad(str, n[, padding_str])
94
94
95
95
#### Arguments
96
96
97
-
-**str**: String expression to operate on. Can be a constant, column, or function, and any combination of string operators.
97
+
-**str**: String expression to operate on. Can be a constant, column, or function, and any combination of operators.
98
98
-**n**: String length to pad to.
99
99
-**padding_str**: String expression to pad with. Can be a constant, column, or function, and any combination of string operators. _Default is a space._
-**expression**: Expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
211
+
-**expression**: String expression to operate on. Can be a constant, column, or function, and any combination of operators.
212
212
-**format_n**: Optional [Chrono format](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) strings to use to parse the expression. Formats will be tried in the order
213
213
they appear with the first successful one being returned. If none of the formats successfully parse the expression
214
214
an error will be returned.
@@ -246,4 +246,4 @@ sha224(expression)
246
246
247
247
#### Arguments
248
248
249
-
-**expression**: String expression to operate on. Can be a constant, column, or function, and any combination of string operators.
249
+
-**expression**: String expression to operate on. Can be a constant, column, or function, and any combination of operators.
0 commit comments