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 fde6d3e576e47..b12d0371bdcdf 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 @@ -3455,6 +3455,13 @@ object functions { /** * Returns an array of elements for which a predicate holds in a given array. + * {{{ + * df.select(filter(col("s"), x => x % 2 === 0)) + * df.selectExpr("filter(col, x -> x % 2 == 0)") + * }}} + * + * @param column: the input array column + * @param f: col => predicate, the boolean predicate to filter the input column * * @group collection_funcs * @since 3.0.0 @@ -3465,6 +3472,14 @@ object functions { /** * Returns an array of elements for which a predicate holds in a given array. + * {{{ + * df.select(filter(col("s"), (x, i) => i % 2 === 0)) + * df.selectExpr("filter(col, (x, i) -> i % 2 == 0)") + * }}} + * + * @param column: the input array column + * @param f: (col, index) => predicate, the boolean predicate to filter the input column + * given the index. Indices start at 0. * * @group collection_funcs * @since 3.0.0