Skip to content

Commit

Permalink
deprecated callUdf in favor of callUDF
Browse files Browse the repository at this point in the history
  • Loading branch information
BenFradet committed Jun 17, 2015
1 parent 104f30c commit cbd80a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/functions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,25 @@ object functions {

// scalastyle:on

/**
* Call an user-defined function.
* Example:
* {{{
* import org.apache.spark.sql._
*
* val df = Seq(("id1", 1), ("id2", 4), ("id3", 5)).toDF("id", "value")
* val sqlContext = df.sqlContext
* sqlContext.udf.register("simpleUdf", (v: Int) => v * v)
* df.select($"id", callUDF("simpleUdf", $"value"))
* }}}
*
* @group udf_funcs
* @since 1.5.0
*/
def callUDF(udfName: String, cols: Column*): Column = {
UnresolvedFunction(udfName, cols.map(_.expr))
}

/**
* Call an user-defined function.
* Example:
Expand All @@ -1652,7 +1671,9 @@ object functions {
*
* @group udf_funcs
* @since 1.4.0
* @deprecated As of 1.5.0, since it was not coherent to have two functions callUdf and callUDF
*/
@deprecated("Use callUDF", "1.5.0")
def callUdf(udfName: String, cols: Column*): Column = {
UnresolvedFunction(udfName, cols.map(_.expr))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class DataFrameSuite extends QueryTest {
val sqlctx = df.sqlContext
sqlctx.udf.register("simpleUdf", (v: Int) => v * v)
checkAnswer(
df.select($"id", callUdf("simpleUdf", $"value")),
df.select($"id", callUDF("simpleUdf", $"value")),
Row("id1", 1) :: Row("id2", 16) :: Row("id3", 25) :: Nil)
}

Expand Down

0 comments on commit cbd80a5

Please sign in to comment.