Skip to content
Closed
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
2 changes: 2 additions & 0 deletions R/pkg/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ exportMethods("%<=>%",
"crc32",
"create_array",
"create_map",
"csc",
"current_date",
"current_timestamp",
"hash",
Expand Down Expand Up @@ -393,6 +394,7 @@ exportMethods("%<=>%",
"rtrim",
"schema_of_csv",
"schema_of_json",
"sec",
"second",
"sha1",
"sha2",
Expand Down
26 changes: 26 additions & 0 deletions R/pkg/R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions R/pkg/R/generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") })
Expand Down Expand Up @@ -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") })
Expand Down
2 changes: 1 addition & 1 deletion R/pkg/tests/fulltests/test_sparkSQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down