New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable binder in generated column expression refers to table column #5739
Comments
I misremembered, we do allow creating generated columns that don't refer to columns of the table, but we don't support creating a table only containing a generated column
Though your error seems unrelated to that, your example would produce this error, if not for the current one. |
This was the smallest example I could come up with for the error. My actual use case is I have a table with a text column and I want to split it and filter the contents. The query below is closer in spirit CREATE TABLE test (
nums INTEGER[],
evens INTEGER[] GENERATED ALWAYS AS
(list_filter(nums, x -> x%2=0)) VIRTUAL
) |
Ah then yes, we should fix that |
Another error, probably the same cause though, CREATE TABLE test (
nums INTEGER[],
evens INTEGER[] GENERATED ALWAYS AS
(list_filter(nums, nums -> TRUE)) VIRTUAL
) gives |
That sounds like a bug, but it would just throw another error when fixed D create table tbl as select [5,4,3] as a;
D select * from tbl;
┌───────────┐
│ a │
│ int32[] │
├───────────┤
│ [5, 4, 3] │
└───────────┘
D select list_filter(a, a -> True) from tbl;
Error: Binder Error: Invalid parameter name 'tbl.a': must be unqualified |
The 'lambda' in the documentation might be suggesting unintended things to me, e.g. scheme/haskell lexical scope where binders can be named arbitrary and inner binders scope most tightly. The binder error Just FWIW (and feel free to ignore/or convert to discussion), another thing I tried was to use a macro in a list filter:
This makes sense as it seems macro/functions are really different from lambda functions. Edit: Of course there's no need to pass the function directly, eta expansion works fine:
This looks like the same behavior as above. |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stale for 30 days with no activity. |
What happens?
Lambda in a select works as expected:
but within a generated column expression
x
is checked as a column reference:BinderException: Binder Error: Column "x" referenced by generated column does not exist
.To Reproduce
OS:
windows,osx,x64
DuckDB Version:
duckdb-0.6.2.dev683-cp37-cp37m-win_amd64
DuckDB Client:
Python, CLI
Full Name:
eaubin
Affiliation:
unaffiliated
Have you tried this on the latest
master
branch?Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
The text was updated successfully, but these errors were encountered: