databend
databend copied to clipboard
bug: using lateral values causes backend error
Search before asking
- [X] I had searched in the issues and found no similar issues.
Version
https://github.com/datafuselabs/databend/releases/tag/v1.2.423-nightly
What's Wrong?
Trying to use lateral values causes a backend error
panicked at src/query/sql/src/planner/binder/values.rs:163:89:
called `Result::unwrap()` on an `Err` value: BadArguments. Code: 1006, Text = Unable to get field named "2". Valid fields: ["col0", "col1"].
Perhaps this is not the correct syntax, please advise if that is the case.
How to Reproduce?
drop table if exists rates;
create table rates(origin varchar, dest varchar, distance int, "r2023" decimal(38,10), "r2022" decimal(38,10), "r2021" decimal(38,10));
insert into rates values ('a', 'b', 500, 2023.12, 2022.23, 2021.34);
WITH source AS(
SELECT origin,
dest,
distance,
"r2023",
"r2022",
"r2021"
FROM "rates"
)
SELECT r.origin, r.dest, r.rates, r.values
FROM (
SELECT source.origin,
source.dest,
v.rates,
v.values
FROM source
JOIN LATERAL (
VALUES
(source."distance", 'distance'),
(source."r2023", 'r2023'),
(source."r2022", 'r2022'),
(source."r2021", 'r2021')
) AS v ("values", "rates") ON true
) AS r
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Cc @xudong963
Perhaps this is not the correct syntax, please advise if that is the case.
The syntax is correct.
This has been fixed by https://github.com/datafuselabs/databend/pull/15561