Skip to content

Commit

Permalink
DataFrame API modification
Browse files Browse the repository at this point in the history
  • Loading branch information
yjshen committed Jul 14, 2015
1 parent 2077888 commit 5486b2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions sql/core/src/main/scala/org/apache/spark/sql/functions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1394,20 +1394,20 @@ object functions {
def round(e: Column): Column = round(e.expr, 0)

/**
* Returns the value of the given column `e` rounded to the value of `scale` decimal places.
* Returns the value of the given column rounded to 0 decimal places.
*
* @group math_funcs
* @since 1.5.0
*/
def round(e: Column, scale: Column): Column = Round(e.expr, scale.expr)
def round(columnName: String): Column = round(Column(columnName), 0)

/**
* Returns the value of `e` rounded to `scale` decimal places.
*
* @group math_funcs
* @since 1.5.0
*/
def round(e: Column, scale: Int): Column = round(e, lit(scale))
def round(e: Column, scale: Int): Column = Round(e.expr, Literal(scale))

/**
* Returns the value of the given column rounded to `scale` decimal places.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,9 @@ class MathExpressionsSuite extends QueryTest {

test("round") {
checkAnswer(
ctx.sql("SELECT round(-32768), round(1809242.3151111344, 9), round(1809242.3151111344, 9)"),
ctx.sql("SELECT round(-32768), round(1809242.3151111344, 9)"),
Seq((1, 2)).toDF().select(
round(lit(-32768)),
round(lit(1809242.3151111344), lit(9)),
round(lit(1809242.3151111344), 9))
)
}
Expand Down

0 comments on commit 5486b2d

Please sign in to comment.