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

bug: and or get different result in databend #4848

Closed
zhyass opened this issue Apr 13, 2022 · 0 comments · Fixed by #4688
Closed

bug: and or get different result in databend #4848

zhyass opened this issue Apr 13, 2022 · 0 comments · Fixed by #4688
Assignees

Comments

@zhyass
Copy link
Member

zhyass commented Apr 13, 2022

In databend:

mysql> select true or true, false or true, false or null, true or null, null or null;
+----------------+-----------------+-----------------+----------------+----------------+
| (true or true) | (false or true) | (false or NULL) | (true or NULL) | (NULL or NULL) |
+----------------+-----------------+-----------------+----------------+----------------+
|              1 |               1 |               0 |              1 |              0 |
+----------------+-----------------+-----------------+----------------+----------------+
1 row in set (0.03 sec)
Read 1 rows, 1 B in 0.006 sec., 167.83 rows/sec., 167.83 B/sec.

mysql> select true and true, false and true, false and null, true and null, null and null;
+-----------------+------------------+------------------+-----------------+-----------------+
| (true and true) | (false and true) | (false and NULL) | (true and NULL) | (NULL and NULL) |
+-----------------+------------------+------------------+-----------------+-----------------+
|               1 |                0 |             NULL |            NULL |            NULL |
+-----------------+------------------+------------------+-----------------+-----------------+
1 row in set (0.03 sec)
Read 1 rows, 1 B in 0.005 sec., 186.57 rows/sec., 186.57 B/sec.

In MySQL:

mysql> select true or true, false or true, false or null, true or null, null or null;
+--------------+---------------+---------------+--------------+--------------+
| true or true | false or true | false or null | true or null | null or null |
+--------------+---------------+---------------+--------------+--------------+
|            1 |             1 |          NULL |            1 |         NULL |
+--------------+---------------+---------------+--------------+--------------+
1 row in set (0.04 sec)

mysql> select true and true, false and true, false and null, true and null, null and null;
+---------------+----------------+----------------+---------------+---------------+
| true and true | false and true | false and null | true and null | null and null |
+---------------+----------------+----------------+---------------+---------------+
|             1 |              0 |              0 |          NULL |          NULL |
+---------------+----------------+----------------+---------------+---------------+
1 row in set (0.04 sec)

In Clickhouse:

0cf42bb123f1 :) select true or true, false or true, false or null, true or null, null or null;

SELECT
    1 OR 1,
    0 OR 1,
    0 OR NULL,
    1 OR NULL,
    NULL OR NULL

Query id: e45d505f-e341-4637-8426-8ac89e208d8d

┌─or(1, 1)─┬─or(0, 1)─┬─or(0, NULL)─┬─or(1, NULL)─┬─or(NULL, NULL)─┐
│        1 │        1 │        ᴺᵁᴸᴸ │           1 │           ᴺᵁᴸᴸ │
└──────────┴──────────┴─────────────┴─────────────┴────────────────┘

1 rows in set. Elapsed: 0.004 sec. 

0cf42bb123f1 :) select true and true, false and true, false and null, true and null, null and null;


SELECT
    1 AND 1,
    0 AND 1,
    0 AND NULL,
    1 AND NULL,
    NULL AND NULL

Query id: d3a3aea9-e2ca-47c1-af2e-285ed8ba260a

┌─and(1, 1)─┬─and(0, 1)─┬─and(0, NULL)─┬─and(1, NULL)─┬─and(NULL, NULL)─┐
│         1 │         0 │            0 │         ᴺᵁᴸᴸ │            ᴺᵁᴸᴸ │
└───────────┴───────────┴──────────────┴──────────────┴─────────────────┘

1 rows in set. Elapsed: 0.002 sec.
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 a pull request may close this issue.

1 participant