apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.3k stars 3.21k forks source link

[Bug] SELECT query result weird #32376

Open mysqldba-nandy opened 5 months ago

mysqldba-nandy commented 5 months ago

Search before asking

Version

1.2.4

What's Wrong?

mysql> select listed_board, count() from security_info group by listed_board order by listed_board;
+--------------+---------+
| listed_board | count() |
+--------------+---------+
| NULL         |  663612 |
| 1            |    3975 |
| 3            |    1973 |
| 4            |     852 |
| 5            |    2479 |
| 6            |     369 |
| 7            |       4 |
| 8            |     482 |
+--------------+---------+
8 rows in set (0.04 sec)

mysql> select count() from security_info where listed_board='1';
+---------+
| count() |
+---------+
|    3904 |
+---------+
1 row in set (0.03 sec)

mysql> select count() from security_info where listed_board=1;
+---------+
| count() |
+---------+
|    3975 |
+---------+
1 row in set (0.03 sec)

The data type of column listed_board is varchar(6), not int. The result of listed_board='1' is weird, on the contrary, listed_board=1 is right.

What You Expected?

The result of select count() from security_info where listed_board='1' should be 3975. Right data type, right result.

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

mysqldba-nandy commented 5 months ago

table definition

CREATE TABLE `security_info` (
  `sec_code_par` varchar(75) NOT NULL,
   ...
  `listed_board` varchar(6) NULL,
   ...
) ENGINE=OLAP
UNIQUE KEY(`sec_code_par`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`sec_code_par`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"in_memory" = "false",
"storage_format" = "V2",
"enable_unique_key_merge_on_write" = "true",
"disable_auto_compaction" = "false"
)