Skip to content

Commit a305168

Browse files
authored
Merge pull request #1143 from Altinity/process_chunks_in_order
Fix parquet writing not preserving original order when using single threaded writing with the native writer
2 parents a9f62d1 + a1c57b1 commit a305168

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Processors/Formats/Impl/ParquetBlockOutputFormat.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,17 @@ void ParquetBlockOutputFormat::writeRowGroup(std::vector<Chunk> chunks)
306306
else
307307
{
308308
Chunk concatenated;
309-
while (!chunks.empty())
309+
for (auto & chunk : chunks)
310310
{
311311
if (concatenated.empty())
312-
concatenated.swap(chunks.back());
312+
{
313+
concatenated.swap(chunk);
314+
}
313315
else
314-
concatenated.append(chunks.back());
315-
chunks.pop_back();
316+
{
317+
concatenated.append(chunk);
318+
chunk.clear(); // free chunk's buffers so memory is release earlier
319+
}
316320
}
317321
writeRowGroupInOneThread(std::move(concatenated));
318322
}

0 commit comments

Comments
 (0)