rawsun007 opened a new issue, #25960:
URL: https://github.com/apache/datafusion/issues/25960

   ### Describe the bug
   
   The SQL reference examples for `any_match`, `array_filter`, `array_first` 
and `array_transform` use lambda syntax (`x -> x > 2`), but none of them run in 
`datafusion-cli` with the default dialect. The `->` is not parsed as a lambda, 
so the error points at the parameter instead:
   
   ```
   > select array_filter([1, 2, 3, 4, 5], x -> x > 2);
   Error: Schema error: No field named x.
   ```
   
   The same happens for the other three examples. They work after switching to 
a dialect whose `supports_lambda_functions()` is true (databricks, duckdb, 
snowflake, spark, clickhouse):
   
   ```
   > set datafusion.sql_parser.dialect = 'duckdb';
   > select array_filter([1, 2, 3, 4, 5], x -> x > 2);
   [3, 4, 5]
   ```
   
   The sqllogictest files for these functions already do this 
(`array_transform.slt` and `array_any_match.slt` start with `set 
datafusion.sql_parser.dialect = databricks;`), so the requirement is known; the 
user guide just doesn't mention it.
   
   ### To Reproduce
   
   `datafusion-cli` built from `main` at 7182e84, then any of the four 
documented examples.
   
   ### Expected behavior
   
   Either the docs say that lambdas need one of those dialects (a note on each 
function, or once at the top of the higher-order functions section), or lambdas 
parse under the default dialect. The note is the small fix. Happy to send a PR 
for it, generated through `dev/update_function_docs.sh` from the `#[user_doc]` 
attributes.
   
   ### Additional context
   
   Found by running every SQL example in `scalar_functions.md` against a `main` 
build. Written with Claude Code (Claude Opus 5.5).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to