Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion/functions-nested/src/array_any_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ make_higher_order_function_expr_and_func!(

#[user_doc(
doc_section(label = "Array Functions"),
description = "Returns whether any elements of an array match the given predicate. Returns true if one or more elements match, false if none match (including empty arrays), and null if the predicate returns null for some elements and false for all others.",
description = "Returns whether any elements of an array match the given predicate. Returns true if one or more elements match, false if none match (including empty arrays), and null if the predicate returns null for some elements and false for all others. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.",
syntax_example = "any_match(array, predicate)",
sql_example = r#"```sql
> select any_match([1, 2, 3], x -> x > 2);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-nested/src/array_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ make_higher_order_function_expr_and_func!(

#[user_doc(
doc_section(label = "Array Functions"),
description = "filters the values of an array using a boolean lambda",
description = "filters the values of an array using a boolean lambda. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional: consider adding SET datafusion.sql_parser.dialect = 'DuckDB'; before the SQL example, and similarly for the other three functions, so each example is self-contained. The existing prose is already correct; if you adopt this, please update the source examples and regenerate the reference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Prajwal-k-tech can you please address @kosiew 's comments?

syntax_example = "array_filter(array, x -> x > 2)",
sql_example = r#"```sql
> select array_filter([1, 2, 3, 4, 5], x -> x > 2);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-nested/src/array_first.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ make_higher_order_function_expr_and_func!(

#[user_doc(
doc_section(label = "Array Functions"),
description = "Returns the first element of an array that satisfies the given predicate. Returns null if the array is empty or no element matches. A predicate that returns null for an element is treated as not matching.",
description = "Returns the first element of an array that satisfies the given predicate. Returns null if the array is empty or no element matches. A predicate that returns null for an element is treated as not matching. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.",
syntax_example = "array_first(array, predicate)",
sql_example = r#"```sql
> select array_first([1, 2, 3, 4], x -> x > 2);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-nested/src/array_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ make_higher_order_function_expr_and_func!(

#[user_doc(
doc_section(label = "Array Functions"),
description = "transforms the values of an array",
description = "transforms the values of an array. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional follow-up: consider adding a DuckDB smoke test to the existing array-transform SLT, verifying that array_transform([1, 2, 3], x -> x * 2) returns [2, 4, 6], then restoring the previous dialect. Existing Databricks tests cover transformation behavior, so this would specifically validate the recommended dialect configuration rather than address a missing correctness test.

syntax_example = "array_transform(array, lambda)",
sql_example = r#"```sql
> select array_transform([1, 2, 3, 4, 5], x -> x*2);
Expand Down
8 changes: 4 additions & 4 deletions docs/source/user-guide/sql/scalar_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,7 @@ array_add(array1, array2)

### `array_any_match`

Returns whether any elements of an array match the given predicate. Returns true if one or more elements match, false if none match (including empty arrays), and null if the predicate returns null for some elements and false for all others.
Returns whether any elements of an array match the given predicate. Returns true if one or more elements match, false if none match (including empty arrays), and null if the predicate returns null for some elements and false for all others. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.

```sql
any_match(array, predicate)
Expand Down Expand Up @@ -3788,7 +3788,7 @@ _Alias of [array_element](#array_element)._

### `array_filter`

filters the values of an array using a boolean lambda
filters the values of an array using a boolean lambda. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.

```sql
array_filter(array, x -> x > 2)
Expand Down Expand Up @@ -3816,7 +3816,7 @@ array_filter(array, x -> x > 2)

### `array_first`

Returns the first element of an array that satisfies the given predicate. Returns null if the array is empty or no element matches. A predicate that returns null for an element is treated as not matching.
Returns the first element of an array that satisfies the given predicate. Returns null if the array is empty or no element matches. A predicate that returns null for an element is treated as not matching. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.

```sql
array_first(array, predicate)
Expand Down Expand Up @@ -4752,7 +4752,7 @@ array_to_string(array, delimiter[, null_string])

### `array_transform`

transforms the values of an array
transforms the values of an array. Lambda expressions require a dialect that supports them; set `datafusion.sql_parser.dialect` to `DuckDB` because the default dialect does not parse the `->` syntax.

```sql
array_transform(array, lambda)
Expand Down
Loading