diff options
author | Dongjoon Hyun <dongjoon@apache.org> | 2016-07-19 10:28:17 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-07-19 10:28:17 -0700 |
commit | 162d04a30e38bb83d35865679145f8ea80b84c26 (patch) | |
tree | cc8d6f2871f792bcd2bc1cd03ef4f0699cda3e89 /sql/hive | |
parent | 0bd76e872b60cb80295fc12654e370cf22390056 (diff) | |
download | spark-162d04a30e38bb83d35865679145f8ea80b84c26.tar.gz spark-162d04a30e38bb83d35865679145f8ea80b84c26.tar.bz2 spark-162d04a30e38bb83d35865679145f8ea80b84c26.zip |
[SPARK-16602][SQL] `Nvl` function should support numeric-string cases
## What changes were proposed in this pull request?
`Nvl` function should support numeric-straing cases like Hive/Spark1.6. Currently, `Nvl` finds the tightest common types among numeric types. This PR extends that to consider `String` type, too.
```scala
- TypeCoercion.findTightestCommonTypeOfTwo(left.dataType, right.dataType).map { dtype =>
+ TypeCoercion.findTightestCommonTypeToString(left.dataType, right.dataType).map { dtype =>
```
**Before**
```scala
scala> sql("select nvl('0', 1)").collect()
org.apache.spark.sql.AnalysisException: cannot resolve `nvl("0", 1)` due to data type mismatch:
input to function coalesce should all be the same type, but it's [string, int]; line 1 pos 7
```
**After**
```scala
scala> sql("select nvl('0', 1)").collect()
res0: Array[org.apache.spark.sql.Row] = Array([0])
```
## How was this patch tested?
Pass the Jenkins tests.
Author: Dongjoon Hyun <dongjoon@apache.org>
Closes #14251 from dongjoon-hyun/SPARK-16602.
Diffstat (limited to 'sql/hive')
0 files changed, 0 insertions, 0 deletions