This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 307c1ea2ef Minor: Add documentation for `cot` (#13069)
307c1ea2ef is described below

commit 307c1ea2ef2323aa347be029039b9daf9b419645
Author: Andrew Lamb <[email protected]>
AuthorDate: Thu Oct 24 11:04:26 2024 -0400

    Minor: Add documentation for `cot` (#13069)
    
    * Add documentation for `cot`
    
    * fmt
---
 datafusion/functions/src/math/cot.rs               | 26 ++++++++++++++++++----
 docs/source/user-guide/sql/scalar_functions_new.md | 13 +++++++++++
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/datafusion/functions/src/math/cot.rs 
b/datafusion/functions/src/math/cot.rs
index f039767536..eded50a20d 100644
--- a/datafusion/functions/src/math/cot.rs
+++ b/datafusion/functions/src/math/cot.rs
@@ -16,18 +16,18 @@
 // under the License.
 
 use std::any::Any;
-use std::sync::Arc;
+use std::sync::{Arc, OnceLock};
 
 use arrow::array::{ArrayRef, AsArray};
 use arrow::datatypes::DataType::{Float32, Float64};
 use arrow::datatypes::{DataType, Float32Type, Float64Type};
 
+use crate::utils::make_scalar_function;
 use datafusion_common::{exec_err, Result};
-use datafusion_expr::ColumnarValue;
+use datafusion_expr::scalar_doc_sections::DOC_SECTION_MATH;
+use datafusion_expr::{ColumnarValue, Documentation};
 use datafusion_expr::{ScalarUDFImpl, Signature, Volatility};
 
-use crate::utils::make_scalar_function;
-
 #[derive(Debug)]
 pub struct CotFunc {
     signature: Signature,
@@ -39,6 +39,20 @@ impl Default for CotFunc {
     }
 }
 
+static DOCUMENTATION: OnceLock<Documentation> = OnceLock::new();
+
+fn get_cot_doc() -> &'static Documentation {
+    DOCUMENTATION.get_or_init(|| {
+        Documentation::builder()
+            .with_doc_section(DOC_SECTION_MATH)
+            .with_description("Returns the cotangent of a number.")
+            .with_syntax_example(r#"cot(numeric_expression)"#)
+            .with_standard_argument("numeric_expression", Some("Numeric"))
+            .build()
+            .unwrap()
+    })
+}
+
 impl CotFunc {
     pub fn new() -> Self {
         use DataType::*;
@@ -77,6 +91,10 @@ impl ScalarUDFImpl for CotFunc {
         }
     }
 
+    fn documentation(&self) -> Option<&Documentation> {
+        Some(get_cot_doc())
+    }
+
     fn invoke(&self, args: &[ColumnarValue]) -> Result<ColumnarValue> {
         make_scalar_function(cot, vec![])(args)
     }
diff --git a/docs/source/user-guide/sql/scalar_functions_new.md 
b/docs/source/user-guide/sql/scalar_functions_new.md
index 7d0280dbc2..55e61984d7 100644
--- a/docs/source/user-guide/sql/scalar_functions_new.md
+++ b/docs/source/user-guide/sql/scalar_functions_new.md
@@ -47,6 +47,7 @@ the rest of the documentation.
 - [ceil](#ceil)
 - [cos](#cos)
 - [cosh](#cosh)
+- [cot](#cot)
 - [degrees](#degrees)
 - [exp](#exp)
 - [factorial](#factorial)
@@ -221,6 +222,18 @@ cosh(numeric_expression)
 
 - **numeric_expression**: Numeric expression to operate on. Can be a constant, 
column, or function, and any combination of operators.
 
+### `cot`
+
+Returns the cotangent of a number.
+
+```
+cot(numeric_expression)
+```
+
+#### Arguments
+
+- **numeric_expression**: Numeric expression to operate on. Can be a constant, 
column, or function, and any combination of operators.
+
 ### `degrees`
 
 Converts radians to degrees.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to