-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Description
What happens?
We think we found a very specific edge case when upgrading from 1.0.0 to 1.1.0 or 1.2.0.
The following reproduction sql produces this error and the error can be avoided with any of the changes I have listed in the sql block.
Binder Error:
Contents of view were altered: types don't match! Expected [VARCHAR, VARCHAR, INTEGER], but found [VARCHAR, VARCHAR, "NULL"] instead
We believe the specific case that causes this error is sql which:
- creates a view with a null column
- uses a CTE multiple times
- the CTE in question needs to have
group by
which results in only a single group (in this example we use group by 1 and have a single row)
Thanks so much!
To Reproduce
-- EXAMPLE 4 (pt1): Comment the following lines to see it work
-- If you don't create a view then there is no error
CREATE VIEW
"tbl1" AS
-- End of EXAMPLE 4 (pt1)
WITH
data_infra as (
select
'a' as AMES,
'b' as TONG
-- Example 6: Unomment out the following line to see it work
-- If there is more than one resulting row in the group by then there is not error
-- union all
-- select
-- 'c' as AMES,
-- 'b' as TONG
--End Example 6
-- Example 5: Comment out the following line to see it work
-- If there is no group by then there is an error
group by
1
-- End of Example 5
)
SELECT
-- Example 1: Comment the following lines to see it work
-- If the CTE is used only once then there is no error
case
when 'b' in (
select
TONG
from
data_infra
) then 'tong'
else 'Various'
end as collapsed_TONG,
--- End of Example 1
-- Example 2: Comment the following lines to see it work
-- If the CTE is used only once then there is no error
case
when 'ba' in (
select
TONG
from
data_infra
) then 'ames'
else null
end as collapsed_AMES,
--- End of Example 2
-- Example 3: Delete this line to see it work
-- If there is no null column there is no error
NULL AS NULL_COL;
-- Example 4 (pt2): Comment out the following line to see it work
SELECT
*
FROM
"tbl1";
-- End of EXAMPLE 4 (pt2)Exam
OS:
osx arm64
DuckDB Version:
1.1.0 or 1.2.0
DuckDB Client:
CLI
Hardware:
No response
Full Name:
Ames Holm
Affiliation:
Watershed
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
Not applicable - the reproduction does not require a data set
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have