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
1 change: 1 addition & 0 deletions R/pkg/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ exportMethods("%<=>%",
"conv",
"cos",
"cosh",
"cot",
"count",
"count_distinct",
"countDistinct",
Expand Down
13 changes: 13 additions & 0 deletions R/pkg/R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also add it into R/pkg/R/generics.R, and add a simple test at R/pkg/tests/fulltests/test_sparkSQL.R.

Also, let's create a separate JIRA for this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just added.
So, if I add a new function, should I make a JIRA ticket and PR separately just for R implementation?

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,
Expand Down
4 changes: 4 additions & 0 deletions R/pkg/R/generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") })
Expand Down
1 change: 1 addition & 0 deletions R/pkg/tests/fulltests/test_sparkSQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down