Skip to content
Prev Previous commit
Next Next commit
fix pyspark test error
  • Loading branch information
kiszk committed Jun 10, 2018
commit a0b4ac52ff4b6d270431b5e5f1e5d5be2c56108b
12 changes: 6 additions & 6 deletions python/pyspark/sql/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1826,13 +1826,13 @@ def map_from_arrays(col1, col2):
:param col1: name of column containing a set of keys. All elements should not be null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and duplicated?

:param col2: name of column containing a set of values

>>> df = spark.createDataFrame([([2, 5], ["Alice", "Bob"])], ['k', 'v'])
>>> df = spark.createDataFrame([([2, 5], ['a', 'b'])], ['k', 'v'])
>>> df.select(map_from_arrays(df.k, df.v).alias("map")).show()
+----------------------+
| map|
+----------------------+
|[2 -> Alice, 5 -> Bob]|
+----------------------+
+----------------+
| map|
+----------------+
|[2 -> a, 5 -> b]|
+----------------+
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.map_from_arrays(_to_java_column(col1), _to_java_column(col2)))
Expand Down