Skip to content

Commit c87fc6c

Browse files
committed
Fix key filtering for workers
1 parent 2952e64 commit c87fc6c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mysql_ch_replicator/mysql_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ def get_records(self, table_name, order_by, limit, start_value=None, worker_id=N
103103

104104
# Add partitioning filter for parallel processing if needed
105105
if worker_id is not None and total_workers is not None and total_workers > 1:
106-
concat_keys = f"CONCAT_WS('|', {', '.join([f'COALESCE({key}, \"\")' for key in order_by])})"
106+
# Use a list comprehension to build the COALESCE expressions with proper quoting
107+
coalesce_expressions = [f"COALESCE({key}, '')" for key in order_by]
108+
concat_keys = f"CONCAT_WS('|', {', '.join(coalesce_expressions)})"
107109
hash_condition = f"CRC32({concat_keys}) % {total_workers} = {worker_id}"
108110
if where:
109111
where += f'AND {hash_condition} '

0 commit comments

Comments
 (0)