diff --git a/dbms/src/DataStreams/FormatFactory.cpp b/dbms/src/DataStreams/FormatFactory.cpp index f3ab160812a..ea77f3b2c09 100644 --- a/dbms/src/DataStreams/FormatFactory.cpp +++ b/dbms/src/DataStreams/FormatFactory.cpp @@ -148,7 +148,9 @@ static BlockOutputStreamPtr getOutputImpl(const String & name, WriteBuffer & buf else if (name == "PrettyCompactMonoBlock") { BlockOutputStreamPtr dst = std::make_shared(buf, false, settings.output_format_pretty_max_rows, context); - return std::make_shared(dst, settings.output_format_pretty_max_rows, 0); + auto res = std::make_shared(dst, settings.output_format_pretty_max_rows, 0); + res->disableFlush(); + return res; } else if (name == "PrettySpace") return std::make_shared(buf, false, settings.output_format_pretty_max_rows, context); diff --git a/dbms/src/DataStreams/PrettyBlockOutputStream.cpp b/dbms/src/DataStreams/PrettyBlockOutputStream.cpp index c7eee1fe4eb..f6a7dab3081 100644 --- a/dbms/src/DataStreams/PrettyBlockOutputStream.cpp +++ b/dbms/src/DataStreams/PrettyBlockOutputStream.cpp @@ -60,7 +60,7 @@ void PrettyBlockOutputStream::calculateWidths(const Block & block, WidthsPerColu { { WriteBufferFromString out(serialized_value); - elem.type->serializeTextEscaped(*elem.column, i, out); + elem.type->serializeTextEscaped(*elem.column, j, out); } widths[i][j] = UTF8::countCodePoints(reinterpret_cast(serialized_value.data()), serialized_value.size()); diff --git a/dbms/src/DataStreams/PrettyBlockOutputStream.h b/dbms/src/DataStreams/PrettyBlockOutputStream.h index a6be5b8f7f5..9c6eef51705 100644 --- a/dbms/src/DataStreams/PrettyBlockOutputStream.h +++ b/dbms/src/DataStreams/PrettyBlockOutputStream.h @@ -44,7 +44,7 @@ protected: const Context & context; using Widths = PODArray; - using WidthsPerColumn = PODArray; + using WidthsPerColumn = std::vector; static void calculateWidths(const Block & block, WidthsPerColumn & widths, Widths & max_widths, Widths & name_widths); void writeValueWithPadding(const ColumnWithTypeAndName & elem, size_t row_num, size_t value_width, size_t pad_to_width); diff --git a/dbms/src/DataStreams/SquashingBlockOutputStream.cpp b/dbms/src/DataStreams/SquashingBlockOutputStream.cpp index 2826f1efb56..ff340926c90 100644 --- a/dbms/src/DataStreams/SquashingBlockOutputStream.cpp +++ b/dbms/src/DataStreams/SquashingBlockOutputStream.cpp @@ -33,7 +33,8 @@ void SquashingBlockOutputStream::finalize() void SquashingBlockOutputStream::flush() { - finalize(); + if (!disable_flush) + finalize(); output->flush(); } diff --git a/dbms/src/DataStreams/SquashingBlockOutputStream.h b/dbms/src/DataStreams/SquashingBlockOutputStream.h index 895356638fa..df3cf262fa6 100644 --- a/dbms/src/DataStreams/SquashingBlockOutputStream.h +++ b/dbms/src/DataStreams/SquashingBlockOutputStream.h @@ -20,6 +20,9 @@ public: void writePrefix() override; void writeSuffix() override; + /// Don't write blocks less than specified size even when flush method was called by user. + void disableFlush() { disable_flush = true; } + private: BlockOutputStreamPtr output; @@ -27,6 +30,8 @@ private: bool all_written = false; void finalize(); + + bool disable_flush = false; }; }