Skip to content
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

Fuzzer 16: Between type mismatch #6194

Merged
merged 1 commit into from
Feb 11, 2023

Conversation

LindsayWray
Copy link

Fuzzer issue #5984 no. 16

Problem query:

CREATE TABLE t0 (c1 USMALLINT);
SELECT 1 FROM (SELECT 1) t1(c0) JOIN t0 ON c1 BETWEEN c0 AND 1;
——
Assertion : left.GetType() == right.GetType() && result.GetType() == LogicalType::BOOLEAN

My findings:
The JOIN condition is split into filter expressions ( c0 <= c1 ) and (c1 <= 1) and after that,
an additional transitive filter is created to compare c0 with 1.
However the expression (c1 <= 1) seems to have cast the constant’s logical type to USMALLINT in a previous optimizer step, probably because it’s more efficient than casting the entire c1 column.
But this in turn causes a problem when comparing c0 with 1 (INT <= USMALLINT)

My current solution is to only create transitive filters when the logical types match.

This does not solve the second problem query from the fuzzer issue though, so that part still needs fixing :(

CREATE TABLE t0 (c0 INT);
SELECT 0 FROM t0 WHERE c0 IN (0) SIMILAR TO decode('a'::BLOB);

@Mytherin
Copy link
Collaborator

Thanks! LGTM

@Mytherin Mytherin merged commit 9ce436a into duckdb:master Feb 11, 2023
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.

None yet

2 participants