diff --git a/R/pkg/NAMESPACE b/R/pkg/NAMESPACE index 686a49e44dfa..5de7aeb8d2d6 100644 --- a/R/pkg/NAMESPACE +++ b/R/pkg/NAMESPACE @@ -267,6 +267,7 @@ exportMethods("%<=>%", "crc32", "create_array", "create_map", + "csc", "current_date", "current_timestamp", "hash", @@ -393,6 +394,7 @@ exportMethods("%<=>%", "rtrim", "schema_of_csv", "schema_of_json", + "sec", "second", "sha1", "sha2", diff --git a/R/pkg/R/functions.R b/R/pkg/R/functions.R index f0768c7e1d83..987d11087d42 100644 --- a/R/pkg/R/functions.R +++ b/R/pkg/R/functions.R @@ -928,6 +928,19 @@ setMethod("crc32", column(jc) }) +#' @details +#' \code{csc}: Returns the cosecant of the given value. +#' +#' @rdname column_math_functions +#' @aliases csc csc,Column-method +#' @note csc since 3.3.0 +setMethod("csc", + signature(x = "Column"), + function(x) { + jc <- callJStatic("org.apache.spark.sql.functions", "csc", x@jc) + column(jc) + }) + #' @details #' \code{hash}: Calculates the hash code of given columns, and returns the result #' as an int column. @@ -3390,6 +3403,19 @@ setMethod("rpad", signature(x = "Column", len = "numeric", pad = "character"), column(jc) }) +#' @details +#' \code{sec}: Returns the secant of the given value. +#' +#' @rdname column_math_functions +#' @aliases sec sec,Column-method +#' @note sec since 3.3.0 +setMethod("sec", + signature(x = "Column"), + function(x) { + jc <- callJStatic("org.apache.spark.sql.functions", "sec", x@jc) + column(jc) + }) + #' @details #' \code{substring_index}: Returns the substring from string (\code{x}) before \code{count} #' occurrences of the delimiter (\code{delim}). If \code{count} is positive, everything the left of diff --git a/R/pkg/R/generics.R b/R/pkg/R/generics.R index 1abde65391e9..9da818bdfbde 100644 --- a/R/pkg/R/generics.R +++ b/R/pkg/R/generics.R @@ -955,6 +955,10 @@ setGeneric("create_array", function(x, ...) { standardGeneric("create_array") }) #' @name NULL setGeneric("create_map", function(x, ...) { standardGeneric("create_map") }) +#' @rdname column_math_functions +#' @name NULL +setGeneric("csc", function(x) { standardGeneric("csc") }) + #' @rdname column_misc_functions #' @name NULL setGeneric("hash", function(x, ...) { standardGeneric("hash") }) @@ -1332,6 +1336,10 @@ setGeneric("schema_of_json", function(x, ...) { standardGeneric("schema_of_json" #' @name NULL setGeneric("sd", function(x, na.rm = FALSE) { standardGeneric("sd") }) +#' @rdname column_math_functions +#' @name NULL +setGeneric("sec", function(x) { standardGeneric("sec") }) + #' @rdname column_datetime_functions #' @name NULL setGeneric("second", function(x) { standardGeneric("second") }) diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R b/R/pkg/tests/fulltests/test_sparkSQL.R index f0cb2745e1d6..bd5c25074b21 100644 --- a/R/pkg/tests/fulltests/test_sparkSQL.R +++ b/R/pkg/tests/fulltests/test_sparkSQL.R @@ -1435,7 +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) + c31 <- sec(c1) + csc(c1) + cot(c1) # Test if base::is.nan() is exposed expect_equal(is.nan(c("a", "b")), c(FALSE, FALSE))