diff --git a/R/pkg/NAMESPACE b/R/pkg/NAMESPACE index 1f0b69db6515..7fa80853fd23 100644 --- a/R/pkg/NAMESPACE +++ b/R/pkg/NAMESPACE @@ -259,6 +259,7 @@ exportMethods("%<=>%", "conv", "cos", "cosh", + "cot", "count", "count_distinct", "countDistinct", diff --git a/R/pkg/R/functions.R b/R/pkg/R/functions.R index 40642f19acc1..62066da10d0d 100644 --- a/R/pkg/R/functions.R +++ b/R/pkg/R/functions.R @@ -870,6 +870,19 @@ setMethod("cosh", column(jc) }) +#' @details +#' \code{cot}: Returns the cotangent of the given value. +#' +#' @rdname column_math_functions +#' @aliases cot cot,Column-method +#' @note cot since 3.3.0 +setMethod("cot", + signature(x = "Column"), + function(x) { + jc <- callJStatic("org.apache.spark.sql.functions", "cot", x@jc) + column(jc) + }) + #' Returns the number of items in a group #' #' This can be used as a column aggregate function with \code{Column} as input, diff --git a/R/pkg/R/generics.R b/R/pkg/R/generics.R index 38ad5f742ca6..9ebea3f55e69 100644 --- a/R/pkg/R/generics.R +++ b/R/pkg/R/generics.R @@ -927,6 +927,10 @@ setGeneric("concat_ws", function(sep, x, ...) { standardGeneric("concat_ws") }) #' @name NULL setGeneric("conv", function(x, fromBase, toBase) { standardGeneric("conv") }) +#' @rdname column_math_functions +#' @name NULL +setGeneric("cot", function(x) { standardGeneric("cot") }) + #' @rdname column_aggregate_functions #' @name NULL setGeneric("count_distinct", function(x, ...) { standardGeneric("count_distinct") }) diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R b/R/pkg/tests/fulltests/test_sparkSQL.R index c10f6eddc389..b97c50074993 100644 --- a/R/pkg/tests/fulltests/test_sparkSQL.R +++ b/R/pkg/tests/fulltests/test_sparkSQL.R @@ -1435,6 +1435,7 @@ test_that("column functions", { desc_nulls_first(c1) + desc_nulls_last(c1) c29 <- acosh(c1) + asinh(c1) + atanh(c1) c30 <- product(c1) + product(c1 * 0.5) + c31 <- cot(c1) # Test if base::is.nan() is exposed expect_equal(is.nan(c("a", "b")), c(FALSE, FALSE))