spark-instrumented-optimizer/python/pyspark/sql
Dongjoon Hyun 14869ae64e [SPARK-14639] [PYTHON] [R] Add bround function in Python/R.
## What changes were proposed in this pull request?

This issue aims to expose Scala `bround` function in Python/R API.
`bround` function is implemented in SPARK-14614 by extending current `round` function.
We used the following semantics from Hive.
```java
public static double bround(double input, int scale) {
    if (Double.isNaN(input) || Double.isInfinite(input)) {
      return input;
    }
    return BigDecimal.valueOf(input).setScale(scale, RoundingMode.HALF_EVEN).doubleValue();
}
```

After this PR, `pyspark` and `sparkR` also support `bround` function.

**PySpark**
```python
>>> from pyspark.sql.functions import bround
>>> sqlContext.createDataFrame([(2.5,)], ['a']).select(bround('a', 0).alias('r')).collect()
[Row(r=2.0)]
```

**SparkR**
```r
> df = createDataFrame(sqlContext, data.frame(x = c(2.5, 3.5)))
> head(collect(select(df, bround(df$x, 0))))
  bround(x, 0)
1            2
2            4
```

## How was this patch tested?

Pass the Jenkins tests (including new testcases).

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #12509 from dongjoon-hyun/SPARK-14639.
2016-04-19 22:28:11 -07:00
..
__init__.py [SPARK-12600][SQL] Remove deprecated methods in Spark SQL 2016-01-04 18:02:38 -08:00
column.py [SPARK-14088][SQL] Some Dataset API touch-up 2016-03-22 23:43:09 -07:00
context.py [SPARK-14573][PYSPARK][BUILD] Fix PyDoc Makefile & highlighting issues 2016-04-14 09:42:15 +01:00
dataframe.py [SPARK-14717] [PYTHON] Scala, Python APIs for Dataset.unpersist differ in default blocking value 2016-04-19 17:29:28 -07:00
functions.py [SPARK-14639] [PYTHON] [R] Add bround function in Python/R. 2016-04-19 22:28:11 -07:00
group.py [SPARK-12756][SQL] use hash expression in Exchange 2016-01-13 22:43:28 -08:00
readwriter.py [SPARK-14231] [SQL] JSON data source infers floating-point values as a double when they do not fit in a decimal 2016-04-02 23:12:04 -07:00
tests.py [SPARK-14717] [PYTHON] Scala, Python APIs for Dataset.unpersist differ in default blocking value 2016-04-19 17:29:28 -07:00
types.py [SPARK-13593] [SQL] improve the createDataFrame to accept data type string and verify the data 2016-03-08 14:00:03 -08:00
utils.py [SPARK-14211][SQL] Remove ANTLR3 based parser 2016-03-31 09:25:09 -07:00
window.py [SPARK-14058][PYTHON] Incorrect docstring in Window.order 2016-03-21 23:52:33 -07:00