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

Wrong query result with convert_query_to_cnf + optimize_using_constraints #57400

Closed
Algunenano opened this issue Nov 30, 2023 · 1 comment · Fixed by #64256
Closed

Wrong query result with convert_query_to_cnf + optimize_using_constraints #57400

Algunenano opened this issue Nov 30, 2023 · 1 comment · Fixed by #64256
Labels
bug Confirmed user-visible misbehaviour in official release

Comments

@Algunenano
Copy link
Member

Comes from 02725_cnf_large_check.sql:

Setup

CREATE TABLE 02725_cnf (c0 UInt8, c1 UInt8, c2 UInt8, c3 UInt8, c4 UInt8, c5 UInt8, c6 UInt8, c7 UInt8, c8 UInt8, c9 UInt8) ENGINE = Memory;

INSERT INTO 02725_cnf VALUES (0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 1), (0, 0, 0, 0, 0, 0, 0, 0, 1, 0), (0, 0, 0, 0, 0, 0, 0, 0, 1, 1), (0, 0, 0, 0, 0, 0, 0, 1, 0, 0), (0, 0, 0, 0, 0, 0, 0, 1, 0, 1), (0, 0, 0, 0, 0, 0, 0, 1, 1, 0), (0, 0, 0, 0, 0, 0, 0, 1, 1, 1);

Default settings:

SELECT count()
FROM `02725_cnf`
WHERE ((NOT c2) AND c2 AND (NOT c1)) OR ((NOT c2) AND c3 AND (NOT c5)) OR ((NOT c7) AND (NOT c8)) OR (c9 AND c6 AND c8 AND (NOT c8) AND (NOT c7))

Query id: b2f5bc62-1eec-40d4-bf48-720233d7c611

┌─count()─┐
│       2 │
└─────────┘

With convert_query_to_cnf and optimize_using_constraints:

SELECT count()
FROM `02725_cnf`
WHERE ((NOT c2) AND c2 AND (NOT c1)) OR ((NOT c2) AND c3 AND (NOT c5)) OR ((NOT c7) AND (NOT c8)) OR (c9 AND c6 AND c8 AND (NOT c8) AND (NOT c7))
SETTINGS convert_query_to_cnf = 1, optimize_using_constraints = 1

Query id: b1fc0d50-e581-4211-aa35-4ef0f3bf8903

┌─count()─┐
│       8 │
└─────────┘

1 row in set. Elapsed: 0.008 sec. 

Enabling only one of them does not trigger the problem. Fails both with and without the analyzer.

@Algunenano Algunenano added the bug Confirmed user-visible misbehaviour in official release label Nov 30, 2023
@Algunenano
Copy link
Member Author

Fails both with and without the analyzer too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant