Chung WONG
12/04/2025, 3:29 AMCREATE 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?Евгений Шишкин
12/04/2025, 5:54 AMChung WONG
12/04/2025, 5:55 AM