@@ -828,30 +828,49 @@ async def process_insert_query(
828828 await self .send_query (query_without_data , query_id = query_id )
829829 await self .send_external_tables (external_tables , types_check = types_check )
830830
831- sample_block = await self .receive_sample_block ()
831+ sample_block = await self ._receive_sample_block ()
832832 if sample_block :
833833 rv = await self .send_data (
834834 sample_block , data , types_check = types_check , columnar = columnar
835835 )
836- packet = await self ._receive_packet ()
837- if packet .exception :
838- raise packet .exception
836+ await self ._receive_end_of_stream ()
837+
839838 return rv
840839
841- async def receive_sample_block (self ):
840+ async def _receive_sample_block (self ):
842841 while True :
843842 packet = await self ._receive_packet ()
844843
845844 if packet .type == ServerPacket .DATA :
846845 return packet .block
847-
848846 elif packet .type == ServerPacket .EXCEPTION :
849847 raise packet .exception
850848 elif packet .type == ServerPacket .LOG :
851- self . log_block ( packet . block )
849+ pass
852850 elif packet .type == ServerPacket .TABLE_COLUMNS :
853851 pass
852+ else :
853+ message = self .unexpected_packet_message (
854+ "Data, Exception or TableColumns" , packet .type
855+ )
856+ raise UnexpectedPacketFromServerError (message )
854857
858+ async def _receive_end_of_stream (self ):
859+ while True :
860+ packet = await self ._receive_packet ()
861+
862+ if packet .type == ServerPacket .END_OF_STREAM :
863+ return
864+ elif packet .type == ServerPacket .EXCEPTION :
865+ raise packet .exception
866+ elif packet .type == ServerPacket .LOG :
867+ pass
868+ elif packet .type == ServerPacket .PROFILE_INFO :
869+ pass
870+ elif packet .type == ServerPacket .PROFILE_EVENTS :
871+ pass
872+ elif packet .type == ServerPacket .PROGRESS :
873+ pass
855874 else :
856875 message = self .unexpected_packet_message (
857876 "Data, Exception or TableColumns" , packet .type
0 commit comments