diff options
author | Wenchen Fan <wenchen@databricks.com> | 2016-08-03 11:15:09 -0700 |
---|---|---|
committer | Yin Huai <yhuai@databricks.com> | 2016-08-03 11:15:09 -0700 |
commit | b55f34370f695de355b72c1518b5f2a45c324af0 (patch) | |
tree | 37b2d3e984c8de7e1c2e1cf43d31eed716981077 /sql/core | |
parent | 639df046a250873c26446a037cb832ab28cb5272 (diff) | |
download | spark-b55f34370f695de355b72c1518b5f2a45c324af0.tar.gz spark-b55f34370f695de355b72c1518b5f2a45c324af0.tar.bz2 spark-b55f34370f695de355b72c1518b5f2a45c324af0.zip |
[SPARK-16714][SPARK-16735][SPARK-16646] array, map, greatest, least's type coercion should handle decimal type
## What changes were proposed in this pull request?
Here is a table about the behaviours of `array`/`map` and `greatest`/`least` in Hive, MySQL and Postgres:
| |Hive|MySQL|Postgres|
|---|---|---|---|---|
|`array`/`map`|can find a wider type with decimal type arguments, and will truncate the wider decimal type if necessary|can find a wider type with decimal type arguments, no truncation problem|can find a wider type with decimal type arguments, no truncation problem|
|`greatest`/`least`|can find a wider type with decimal type arguments, and truncate if necessary, but can't do string promotion|can find a wider type with decimal type arguments, no truncation problem, but can't do string promotion|can find a wider type with decimal type arguments, no truncation problem, but can't do string promotion|
I think these behaviours makes sense and Spark SQL should follow them.
This PR fixes `array` and `map` by using `findWiderCommonType` to get the wider type.
This PR fixes `greatest` and `least` by add a `findWiderTypeWithoutStringPromotion`, which provides similar semantic of `findWiderCommonType`, but without string promotion.
## How was this patch tested?
new tests in `TypeCoersionSuite`
Author: Wenchen Fan <wenchen@databricks.com>
Author: Yin Huai <yhuai@databricks.com>
Closes #14439 from cloud-fan/bug.
Diffstat (limited to 'sql/core')
0 files changed, 0 insertions, 0 deletions