diff options
author | Wenchen Fan <wenchen@databricks.com> | 2016-03-25 09:50:06 -0700 |
---|---|---|
committer | Yin Huai <yhuai@databricks.com> | 2016-03-25 09:50:06 -0700 |
commit | 43b15e01c46ea1971569f74c9201a55de39e8917 (patch) | |
tree | 699a834d375d70d2a2de9cd46f8eda394e4dea6c /sql/core/src/main | |
parent | 6603d9f7e283cf8199cfddfeea30d9db39669726 (diff) | |
download | spark-43b15e01c46ea1971569f74c9201a55de39e8917.tar.gz spark-43b15e01c46ea1971569f74c9201a55de39e8917.tar.bz2 spark-43b15e01c46ea1971569f74c9201a55de39e8917.zip |
[SPARK-14061][SQL] implement CreateMap
## What changes were proposed in this pull request?
As we have `CreateArray` and `CreateStruct`, we should also have `CreateMap`. This PR adds the `CreateMap` expression, and the DataFrame API, and python API.
## How was this patch tested?
various new tests.
Author: Wenchen Fan <wenchen@databricks.com>
Closes #11879 from cloud-fan/create_map.
Diffstat (limited to 'sql/core/src/main')
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/functions.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index 304d747d4f..8abb9d7e4a 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -905,6 +905,17 @@ object functions { } /** + * Creates a new map column. The input columns must be grouped as key-value pairs, e.g. + * (key1, value1, key2, value2, ...). The key columns must all have the same data type, and can't + * be null. The value columns must all have the same data type. + * + * @group normal_funcs + * @since 2.0 + */ + @scala.annotation.varargs + def map(cols: Column*): Column = withExpr { CreateMap(cols.map(_.expr)) } + + /** * Marks a DataFrame as small enough for use in broadcast joins. * * The following example marks the right DataFrame for broadcast hash join using `joinKey`. |