@@ -4785,6 +4785,32 @@ def array_flatten(array: ColumnOrName, _emit_ast: bool = True) -> Column:
47854785 return builtin ("array_flatten" , _emit_ast = _emit_ast )(array )
47864786
47874787
4788+ @publicapi
4789+ def array_reverse (col : ColumnOrName , _emit_ast : bool = True ) -> Column :
4790+ """Returns an array with the elements of the input array in reverse order.
4791+
4792+ Args:
4793+ col: The source array.
4794+
4795+ Example::
4796+ >>> df = session.sql("select [1, 2, 3, 4] :: ARRAY(INT) as A")
4797+ >>> df.select(array_reverse("A")).show()
4798+ --------------------------
4799+ |"ARRAY_REVERSE(""A"")" |
4800+ --------------------------
4801+ |[ |
4802+ | 4, |
4803+ | 3, |
4804+ | 2, |
4805+ | 1 |
4806+ |] |
4807+ --------------------------
4808+ <BLANKLINE>
4809+ """
4810+ array = _to_col_if_str (col , "array_reverse" )
4811+ return builtin ("array_reverse" , _emit_ast = _emit_ast )(array )
4812+
4813+
47884814@publicapi
47894815def array_sort (
47904816 array : ColumnOrName ,
@@ -6933,6 +6959,88 @@ def array_unique_agg(col: ColumnOrName, _emit_ast: bool = True) -> Column:
69336959 return _call_function ("array_unique_agg" , True , c , _emit_ast = _emit_ast )
69346960
69356961
6962+ @publicapi
6963+ def map_cat (col1 : ColumnOrName , col2 : ColumnOrName , _emit_ast : bool = True ):
6964+ """Returns the concatenatation of two MAPs.
6965+
6966+ Args:
6967+ col1: The source map
6968+ col2: The map to be appended to col1
6969+
6970+ Example::
6971+ >>> df = session.sql("select {'k1': 'v1'} :: MAP(STRING,STRING) as A, {'k2': 'v2'} :: MAP(STRING,STRING) as B")
6972+ >>> df.select(map_cat("A", "B")).show()
6973+ ---------------------------
6974+ |"MAP_CAT(""A"", ""B"")" |
6975+ ---------------------------
6976+ |{ |
6977+ | "k1": "v1", |
6978+ | "k2": "v2" |
6979+ |} |
6980+ ---------------------------
6981+ <BLANKLINE>
6982+ """
6983+ m1 = _to_col_if_str (col1 , "map_cat" )
6984+ m2 = _to_col_if_str (col2 , "map_cat" )
6985+ return builtin ("map_cat" , _emit_ast = _emit_ast )(m1 , m2 )
6986+
6987+
6988+ @publicapi
6989+ def map_contains_key (value : ColumnOrLiteral , col : ColumnOrName , _emit_ast : bool = True ):
6990+ """Determines whether the specified MAP contains the specified key.
6991+
6992+ Args:
6993+ value: The key to find.
6994+ col: The map to be searched.
6995+
6996+ Example 1::
6997+ >>> df = session.sql("select {'k1': 'v1'} :: MAP(STRING,STRING) as M, 'k1' as V")
6998+ >>> df.select(map_contains_key(col("V"), "M")).show()
6999+ ------------------------------------
7000+ |"MAP_CONTAINS_KEY(""V"", ""M"")" |
7001+ ------------------------------------
7002+ |True |
7003+ ------------------------------------
7004+ <BLANKLINE>
7005+
7006+ Example 2::
7007+ >>> df = session.sql("select {'k1': 'v1'} :: MAP(STRING,STRING) as M")
7008+ >>> df.select(map_contains_key("k1", "M")).show()
7009+ -----------------------------------
7010+ |"MAP_CONTAINS_KEY('K1', ""M"")" |
7011+ -----------------------------------
7012+ |True |
7013+ -----------------------------------
7014+ <BLANKLINE>
7015+ """
7016+ m = _to_col_if_str (col , "map_contains" )
7017+ return builtin ("map_contains_key" , _emit_ast = _emit_ast )(value , m )
7018+
7019+
7020+ @publicapi
7021+ def map_keys (col : ColumnOrName , _emit_ast : bool = True ):
7022+ """Returns the keys in a MAP.
7023+
7024+ Args:
7025+ col: The input map.
7026+
7027+ Example 1::
7028+ >>> df = session.sql("select {'k1': 'v1', 'k2': 'v2'} :: MAP(STRING,STRING) as M")
7029+ >>> df.select(map_keys("M")).show()
7030+ ---------------------
7031+ |"MAP_KEYS(""M"")" |
7032+ ---------------------
7033+ |[ |
7034+ | "k1", |
7035+ | "k2" |
7036+ |] |
7037+ ---------------------
7038+ <BLANKLINE>
7039+ """
7040+ m = _to_col_if_str (col , "map_keys" )
7041+ return builtin ("map_keys" , _emit_ast = _emit_ast )(m )
7042+
7043+
69367044@publicapi
69377045def size (col : ColumnOrName , _emit_ast : bool = True ) -> Column :
69387046 """Returns the size of the input ARRAY, OBJECT or MAP. Returns NULL if the
@@ -10142,6 +10250,9 @@ def sproc(
1014210250sort_array = array_sort
1014310251map_from_arrays = arrays_to_object
1014410252signum = sign
10253+ array_join = array_to_string
10254+ array_union = array_cat
10255+ map_concat = map_cat
1014510256
1014610257
1014710258@publicapi
0 commit comments