Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions datafusion/expr/src/udf_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,29 @@ impl DocumentationBuilder {

/// Add a standard "expression" argument to the documentation
///
/// This is similar to [`Self::with_argument`] except that a standard
/// description is appended to the end: `"Can be a constant, column, or
/// function, and any combination of arithmetic operators."`
///
/// The argument is rendered like
/// The argument is rendered like below if Some() is passed through:
///
/// ```text
/// <arg_name>:
/// <expression_type> expression to operate on. Can be a constant, column, or function, and any combination of operators.
/// ```
///
/// The argument is rendered like below if None is passed through:
///
/// ```text
/// <arg_name>:
/// The expression to operate on. Can be a constant, column, or function, and any combination of operators.
/// ```
pub fn with_standard_argument(
self,
arg_name: impl Into<String>,
expression_type: impl AsRef<str>,
expression_type: Option<&str>,
) -> Self {
let expression_type = expression_type.as_ref();
self.with_argument(arg_name, format!("{expression_type} expression to operate on. Can be a constant, column, or function, and any combination of operators."))
let description = format!(
"{} expression to operate on. Can be a constant, column, or function, and any combination of operators.",
expression_type.unwrap_or("The")
);
self.with_argument(arg_name, description)
}

pub fn with_related_udf(mut self, related_udf: impl Into<String>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/approx_distinct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn get_approx_distinct_doc() -> &'static Documentation {
+-----------------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/approx_median.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn get_approx_median_doc() -> &'static Documentation {
+-----------------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn get_approx_percentile_cont_doc() -> &'static Documentation {
| 65.0 |
+-------------------------------------------------+
```"#)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.with_argument("percentile", "Percentile to compute. Must be a float value between 0 and 1 (inclusive).")
.with_argument("centroids", "Number of centroids to use in the t-digest algorithm. _Default is 100_. A higher number results in more accurate approximation but requires more memory.")
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn get_approx_percentile_cont_with_weight_doc() -> &'static Documentation {
+----------------------------------------------------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.with_argument("weight", "Expression to use as weight. Can be a constant, column, or function, and any combination of arithmetic operators.")
.with_argument("percentile", "Percentile to compute. Must be a float value between 0 and 1 (inclusive).")
.build()
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/array_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn get_array_agg_doc() -> &'static Documentation {
+-----------------------------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/average.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn get_avg_doc() -> &'static Documentation {
+---------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
6 changes: 3 additions & 3 deletions datafusion/functions-aggregate/src/bit_and_or_xor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fn get_bit_and_doc() -> &'static Documentation {
.with_doc_section(DOC_SECTION_GENERAL)
.with_description("Computes the bitwise AND of all non-null input values.")
.with_syntax_example("bit_and(expression)")
.with_standard_argument("expression", "Integer")
.with_standard_argument("expression", Some("Integer"))
.build()
.unwrap()
})
Expand All @@ -156,7 +156,7 @@ fn get_bit_or_doc() -> &'static Documentation {
.with_doc_section(DOC_SECTION_GENERAL)
.with_description("Computes the bitwise OR of all non-null input values.")
.with_syntax_example("bit_or(expression)")
.with_standard_argument("expression", "Integer")
.with_standard_argument("expression", Some("Integer"))
.build()
.unwrap()
})
Expand All @@ -172,7 +172,7 @@ fn get_bit_xor_doc() -> &'static Documentation {
"Computes the bitwise exclusive OR of all non-null input values.",
)
.with_syntax_example("bit_xor(expression)")
.with_standard_argument("expression", "Integer")
.with_standard_argument("expression", Some("Integer"))
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-aggregate/src/bool_and_or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn get_bool_and_doc() -> &'static Documentation {
+----------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down Expand Up @@ -350,7 +350,7 @@ fn get_bool_or_doc() -> &'static Documentation {
+----------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-aggregate/src/correlation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ fn get_corr_doc() -> &'static Documentation {
+--------------------------------+
```"#,
)
.with_standard_argument("expression1", "First")
.with_standard_argument("expression2", "Second")
.with_standard_argument("expression1", Some("First"))
.with_standard_argument("expression2", Some("Second"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fn get_count_doc() -> &'static Documentation {
| 120 |
+------------------+
```"#)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
8 changes: 4 additions & 4 deletions datafusion/functions-aggregate/src/covariance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ fn get_covar_samp_doc() -> &'static Documentation {
+-----------------------------------+
```"#,
)
.with_standard_argument("expression1", "First")
.with_standard_argument("expression2", "Second")
.with_standard_argument("expression1", Some("First"))
.with_standard_argument("expression2", Some("Second"))
.build()
.unwrap()
})
Expand Down Expand Up @@ -248,8 +248,8 @@ fn get_covar_pop_doc() -> &'static Documentation {
+-----------------------------------+
```"#,
)
.with_standard_argument("expression1", "First")
.with_standard_argument("expression2", "Second")
.with_standard_argument("expression1", Some("First"))
.with_standard_argument("expression2", Some("Second"))
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-aggregate/src/first_last.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn get_first_value_doc() -> &'static Documentation {
+-----------------------------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down Expand Up @@ -519,7 +519,7 @@ fn get_last_value_doc() -> &'static Documentation {
+-----------------------------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/median.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn get_median_doc() -> &'static Documentation {
+----------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-aggregate/src/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fn get_max_doc() -> &'static Documentation {
+----------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down Expand Up @@ -1187,7 +1187,7 @@ fn get_min_doc() -> &'static Documentation {
+----------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/nth_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn get_nth_value_doc() -> &'static Documentation {
| 2 | 45000 | 45000 |
+---------+--------+-------------------------+
```"#)
.with_standard_argument("expression", "The column or expression to retrieve the nth value from.")
.with_argument("expression", "The column or expression to retrieve the nth value from.")
.with_argument("n", "The position (nth) of the value to retrieve, based on the ordering.")
.build()
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-aggregate/src/stddev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn get_stddev_doc() -> &'static Documentation {
+----------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down Expand Up @@ -282,7 +282,7 @@ fn get_stddev_pop_doc() -> &'static Documentation {
+--------------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fn get_sum_doc() -> &'static Documentation {
+-----------------------+
```"#,
)
.with_standard_argument("expression", "The")
.with_standard_argument("expression", None)
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions-aggregate/src/variance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn get_variance_sample_doc() -> &'static Documentation {
"Returns the statistical sample variance of a set of numbers.",
)
.with_syntax_example("var(expression)")
.with_standard_argument("expression", "Numeric")
.with_standard_argument("expression", Some("Numeric"))
.build()
.unwrap()
})
Expand Down Expand Up @@ -259,7 +259,7 @@ fn get_variance_population_doc() -> &'static Documentation {
"Returns the statistical population variance of a set of numbers.",
)
.with_syntax_example("var_pop(expression)")
.with_standard_argument("expression", "Numeric")
.with_standard_argument("expression", Some("Numeric"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/crypto/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn get_digest_doc() -> &'static Documentation {
```"#,
)
.with_standard_argument(
"expression", "String")
"expression", Some("String"))
.with_argument(
"algorithm",
"String expression specifying algorithm to use. Must be one of:
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/crypto/md5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn get_md5_doc() -> &'static Documentation {
+-------------------------------------+
```"#,
)
.with_standard_argument("expression", "String")
.with_standard_argument("expression", Some("String"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/crypto/sha224.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn get_sha224_doc() -> &'static Documentation {
+------------------------------------------+
```"#,
)
.with_standard_argument("expression", "String")
.with_standard_argument("expression", Some("String"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/crypto/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn get_sha256_doc() -> &'static Documentation {
+--------------------------------------+
```"#,
)
.with_standard_argument("expression", "String")
.with_standard_argument("expression", Some("String"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/crypto/sha384.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn get_sha384_doc() -> &'static Documentation {
+-----------------------------------------+
```"#,
)
.with_standard_argument("expression", "String")
.with_standard_argument("expression", Some("String"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/datetime/to_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Note: `to_date` returns Date32, which represents its values as the number of day

Additional examples can be found [here](https://github.com/apache/datafusion/blob/main/datafusion-examples/examples/to_date.rs)
"#)
.with_standard_argument("expression", "String")
.with_standard_argument("expression", Some("String"))
.with_argument(
"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
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/math/abs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn get_abs_doc() -> &'static Documentation {
.with_doc_section(DOC_SECTION_MATH)
.with_description("Returns the absolute value of a number.")
.with_syntax_example("abs(numeric_expression)")
.with_standard_argument("numeric_expression", "Numeric")
.with_standard_argument("numeric_expression", Some("Numeric"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/math/factorial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn get_factorial_doc() -> &'static Documentation {
.with_doc_section(DOC_SECTION_MATH)
.with_description("Factorial. Returns 1 if value is less than 2.")
.with_syntax_example("factorial(numeric_expression)")
.with_standard_argument("numeric_expression", "Numeric")
.with_standard_argument("numeric_expression", Some("Numeric"))
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/src/math/gcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ fn get_gcd_doc() -> &'static Documentation {
"Returns the greatest common divisor of `expression_x` and `expression_y`. Returns 0 if both inputs are zero.",
)
.with_syntax_example("gcd(expression_x, expression_y)")
.with_standard_argument("expression_x", "First numeric")
.with_standard_argument("expression_y", "Second numeric")
.with_standard_argument("expression_x", Some("First numeric"))
.with_standard_argument("expression_y", Some("Second numeric"))
.build()
.unwrap()
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/math/iszero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn get_iszero_doc() -> &'static Documentation {
"Returns true if a given number is +0.0 or -0.0 otherwise returns false.",
)
.with_syntax_example("iszero(numeric_expression)")
.with_standard_argument("numeric_expression", "Numeric")
.with_standard_argument("numeric_expression", Some("Numeric"))
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/src/math/lcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ fn get_lcm_doc() -> &'static Documentation {
"Returns the least common multiple of `expression_x` and `expression_y`. Returns 0 if either input is zero.",
)
.with_syntax_example("lcm(expression_x, expression_y)")
.with_standard_argument("expression_x", "First numeric")
.with_standard_argument("expression_y", "Second numeric")
.with_standard_argument("expression_x", Some("First numeric"))
.with_standard_argument("expression_y", Some("Second numeric"))
.build()
.unwrap()
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/src/math/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn get_log_doc() -> &'static Documentation {
.with_description("Returns the base-x logarithm of a number. Can either provide a specified base, or if omitted then takes the base-10 of a number.")
.with_syntax_example(r#"log(base, numeric_expression)
log(numeric_expression)"#)
.with_standard_argument("base", "Base numeric")
.with_standard_argument("numeric_expression", "Numeric")
.with_standard_argument("base", Some("Base numeric"))
.with_standard_argument("numeric_expression", Some("Numeric"))
.build()
.unwrap()
})
Expand Down
Loading