databend
databend copied to clipboard
bug: Higher order functions in SQL UDFs and queries do not share outer scope.
Search before asking
- [X] I had searched in the issues and found no similar issues.
Version
v1.2.371-a95ac62303
What's Wrong?
if do
create or replace function array_except as (x, y) -> array_filter(x, el -> not contains(y, el));
select array_except([1,2], [2,3]);
I get the following error: column y doesn't exist
if I do
with
t as (select [2,3] as y)
select array_filter([1,2], el -> not contains(y, el)) from t;
I get the same error: column y doesn't exist
If I execute the equivalent SQL using constants it of course works:
select array_filter([1,2], el -> not contains([2,3], el))
-- returns [1]
Not being able to use variables or column aliases in higher order functions significantly limits their utility. I would love to see this fixed!
How to Reproduce?
No response
Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
Hi, @maxjustus Thanks for report the bug. Currently the array lambda function doesn't support external columns, we'll add this in the near future.
Hi @maxjustus the bug has fixed, thanks again for your report.