I am hitting a strange bug when querying my table ...
# questions-and-troubleshooting
c
I am hitting a strange bug when querying my table on StarRocks V4
Copy code
CREATE TABLE `sales` (
  `tenant_id` int(11) NOT NULL COMMENT "",
  `line_id` varchar(255) NOT NULL COMMENT "",
  `created_at` datetime NOT NULL COMMENT "",
  `branch_code` varchar(255) NOT NULL COMMENT ""
) ENGINE=OLAP 
PRIMARY KEY(`tenant_id`, `line_id`, `created_at`)
PARTITION BY date_trunc('month', created_at)
DISTRIBUTED BY HASH(`tenant_id`)
ORDER BY(`created_at`)
PROPERTIES (
"compression" = "LZ4",
"enable_persistent_index" = "true",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "1"
);

MySQL > SELECT
    -> distinct branch_code,
    -> length(branch_code)
    -> FROM `sales`
    -> WHERE branch_code ='C1'
    -> ;
+-------------+---------------------+
| branch_code | length(branch_code) |
+-------------+---------------------+
| C1          |                   2 |
| C1          |                   2 |
+-------------+---------------------+

MySQL [bea]> SELECT branch_code, count(*) FROM `sales` WHERE branch_code ='C1' group by branch_code;
+-------------+----------+
| branch_code | count(*) |
+-------------+----------+
| C1          |      136 |
| C1          |      141 |
+-------------+----------+
I don't understand why it returns two rows? If I dump `SELECT * FROM
sales
WHERE branch_code ='C1'` into a parquet file and import it to another database then it works without the duplication. What could be the reason for it?
е
@Kevin Cai could it be dictionary optimization bug?
c
I actually enhanced the github issue for this bug here https://github.com/StarRocks/starrocks/issues/65570
👍 1