@@ -222,21 +222,31 @@ def convert_table_structure(self, mysql_structure: TableStructure) -> TableStruc
222222 clickhouse_structure .preprocess ()
223223 return clickhouse_structure
224224
225- def convert_records (self , mysql_records , mysql_structure : TableStructure , clickhouse_structure : TableStructure ):
225+ def convert_records (
226+ self , mysql_records , mysql_structure : TableStructure , clickhouse_structure : TableStructure ,
227+ only_primary : bool = False ,
228+ ):
226229 mysql_field_types = [field .field_type for field in mysql_structure .fields ]
227230 clickhouse_filed_types = [field .field_type for field in clickhouse_structure .fields ]
228231
229232 clickhouse_records = []
230233 for mysql_record in mysql_records :
231234 clickhouse_record = self .convert_record (
232- mysql_record , mysql_field_types , clickhouse_filed_types , mysql_structure ,
235+ mysql_record , mysql_field_types , clickhouse_filed_types , mysql_structure , only_primary ,
233236 )
234237 clickhouse_records .append (clickhouse_record )
235238 return clickhouse_records
236239
237- def convert_record (self , mysql_record , mysql_field_types , clickhouse_field_types , mysql_structure : TableStructure ):
240+ def convert_record (
241+ self , mysql_record , mysql_field_types , clickhouse_field_types , mysql_structure : TableStructure ,
242+ only_primary : bool ,
243+ ):
238244 clickhouse_record = []
239245 for idx , mysql_field_value in enumerate (mysql_record ):
246+ if only_primary and idx not in mysql_structure .primary_key_ids :
247+ clickhouse_record .append (mysql_field_value )
248+ continue
249+
240250 clickhouse_field_value = mysql_field_value
241251 mysql_field_type = mysql_field_types [idx ]
242252 clickhouse_field_type = clickhouse_field_types [idx ]
0 commit comments