Skip to content

Conversation

@lovasoa
Copy link
Contributor

@lovasoa lovasoa commented Jan 5, 2026

Summary

This PR adds support for parsing DuckDB's LAMBDA keyword syntax for lambda functions.

DuckDB supports two syntaxes for lambda functions:

  • Arrow syntax: x -> x + 1 (already supported, but deprecated in duckdb)
  • Lambda keyword syntax: lambda x : x + 1 (preferred syntax in duckdb, added in this PR)

Initially reported in sqlpage/SQLPage#1171

Changes

  • Added LAMBDA keyword to keywords list
  • Added LambdaSyntax enum to track which syntax style was used (for correct round-tripping)
  • Added parse_lambda_expr() to parse lambda <params> : <expr> syntax
  • Updated LambdaFunction struct to include syntax field
  • Added tests for DuckDB lambda functions

Examples

-- Single parameter
SELECT list_filter([1, 2, 3], lambda x : x > 1)

-- Multiple parameters (with index)
SELECT list_filter([1, 3, 1, 5], lambda x, i : x > i)

-- Method call syntax
SELECT [3, 4, 5, 6].list_filter(lambda x : x > 4)

Test plan

  • Added test_duckdb_lambda_function test covering single param, multi-param, and method call syntax
  • All existing lambda tests pass (Databricks, ClickHouse, common)
  • All DuckDB tests pass

🤖 Generated with Claude Code and and reviewed by me, @lovasoa, a human.

@lovasoa
Copy link
Contributor Author

lovasoa commented Jan 8, 2026

Hi @iffyio, @alamb ! Do you think you could have a look at this ? The old duckdb lambda syntax is deprecated, so I suppose this is going to pop out more and more. This comes from a bug report in sqlpage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant