Skip to content

Unexpected result when using LEVENSHTEIN #7541

Description

@suyZhong

Describe the bug
Consider the following test cases. I suppose the first query is unexpected: it should return only one row, as the UNION ALL of three queries returns only one row 1 false. Besides, if first insert true in table t0 and then false, the first query returns only one row as expected.

To Reproduce

DROP TABLE IF EXISTS t0 CASCADE;
DROP TABLE IF EXISTS t1 CASCADE;

CREATE TABLE t0 (c0 BOOLEAN);
CREATE TABLE t1 (c1 INT) ;
INSERT INTO t1(c1) VALUES (1);

INSERT INTO t0(c0) VALUES (false); -- should first insert false then true
INSERT INTO t0(c0) VALUES (true);

SELECT * FROM t1 LEFT  JOIN t0 ON LEVENSHTEIN(t0.c0, true); -- 1 false, 1, true (unexpected)
SELECT * FROM t1 LEFT  JOIN t0 ON LEVENSHTEIN(t0.c0, true) WHERE t0.c0 UNION ALL SELECT * FROM t1 LEFT  JOIN t0 ON LEVENSHTEIN(t0.c0, true) WHERE (NOT t0.c0) UNION ALL SELECT * FROM t1 LEFT  JOIN t0 ON LEVENSHTEIN(t0.c0, true) WHERE ((t0.c0) IS NULL); -- 1 false

SELECT LEVENSHTEIN(true, true); -- 0
SELECT LEVENSHTEIN(t0.c0, true) FROM t0; -- 4, 4 (I guess it's unexpected and the root cause)

Expected behavior
As mentioned above.

Screenshots
N/A

Software versions
Build from source:

> docker exec -it monetdb-test mserver5 --version
MonetDB 5 server 11.52.0 (hg id: 736987f) (64-bit, 128-bit integers)
This is an unreleased version
Copyright (c) 1993 - July 2008 CWI
Copyright (c) August 2008 - 2023 MonetDB B.V., all rights reserved
Visit https://www.monetdb.org/ for further information
Found 503.5GiB available memory, 128 available cpu cores
Libraries:
Compiled by: @2195e8c5ad70 (x86_64-pc-linux-gnu)
Compilation: /usr/bin/cc 
Linking    : /usr/bin/ld

Issue labeling
Bug

Additional context
Add any other context about the problem here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions