From f6144ee32bd824367c64c987a094a4f9ddaab0ae Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 13 May 2023 02:45:07 +0300 Subject: [PATCH] Revert "Make `Pretty` formats even prettier." --- src/Core/Settings.h | 1 - src/Formats/FormatFactory.cpp | 1 - src/Formats/FormatSettings.h | 1 - .../Formats/Impl/PrettyBlockOutputFormat.cpp | 26 +++++++------------ .../Formats/Impl/PrettyBlockOutputFormat.h | 10 ++++--- .../Impl/PrettySpaceBlockOutputFormat.cpp | 2 +- .../queries/0_stateless/00098_k_union_all.sql | 1 - .../0_stateless/00405_pretty_formats.sql | 2 -- .../00730_unicode_terminal_format.sql | 2 -- ...065_window_view_event_hop_watch_bounded.py | 8 ++---- .../01082_window_view_watch_limit.py | 8 ++---- ...01509_output_format_pretty_row_numbers.sql | 2 -- ...02122_parallel_formatting_Pretty.reference | 2 ++ .../02122_parallel_formatting_Pretty.sh | 5 ++++ ...arallel_formatting_PrettyCompact.reference | 2 ++ ...02122_parallel_formatting_PrettyCompact.sh | 5 ++++ ...ormatting_PrettyCompactNoEscapes.reference | 2 ++ ...allel_formatting_PrettyCompactNoEscapes.sh | 5 ++++ ...allel_formatting_PrettyNoEscapes.reference | 2 ++ ...122_parallel_formatting_PrettyNoEscapes.sh | 5 ++++ ..._parallel_formatting_PrettySpace.reference | 2 ++ .../02122_parallel_formatting_PrettySpace.sh | 5 ++++ ..._formatting_PrettySpaceNoEscapes.reference | 2 ++ ...arallel_formatting_PrettySpaceNoEscapes.sh | 5 ++++ .../0_stateless/02375_pretty_formats.sql.j2 | 1 - ...2731_pretty_time_based_squashing.reference | 14 ---------- .../02731_pretty_time_based_squashing.sql | 2 -- 27 files changed, 63 insertions(+), 60 deletions(-) create mode 100644 tests/queries/0_stateless/02122_parallel_formatting_Pretty.reference create mode 100755 tests/queries/0_stateless/02122_parallel_formatting_Pretty.sh create mode 100644 tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.reference create mode 100755 tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.sh create mode 100644 tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.reference create mode 100755 tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.sh create mode 100644 tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.reference create mode 100755 tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.sh create mode 100644 tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.reference create mode 100755 tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.sh create mode 100644 tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.reference create mode 100755 tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.sh delete mode 100644 tests/queries/0_stateless/02731_pretty_time_based_squashing.reference delete mode 100644 tests/queries/0_stateless/02731_pretty_time_based_squashing.sql diff --git a/src/Core/Settings.h b/src/Core/Settings.h index 215e5b38056..6e345e7edb1 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -905,7 +905,6 @@ class IColumn; M(UInt64, output_format_pretty_max_value_width, 10000, "Maximum width of value to display in Pretty formats. If greater - it will be cut.", 0) \ M(Bool, output_format_pretty_color, true, "Use ANSI escape sequences to paint colors in Pretty formats", 0) \ M(String, output_format_pretty_grid_charset, "UTF-8", "Charset for printing grid borders. Available charsets: ASCII, UTF-8 (default one).", 0) \ - M(Milliseconds, output_format_pretty_squash_ms, 100, "Squash blocks in Pretty formats if the time passed after the previous block is not greater than the specified threshold in milliseconds. This avoids printing miltiple small blocks.", 0) \ M(UInt64, output_format_parquet_row_group_size, 1000000, "Target row group size in rows.", 0) \ M(UInt64, output_format_parquet_row_group_size_bytes, 512 * 1024 * 1024, "Target row group size in bytes, before compression.", 0) \ M(Bool, output_format_parquet_string_as_string, false, "Use Parquet String type instead of Binary for String columns.", 0) \ diff --git a/src/Formats/FormatFactory.cpp b/src/Formats/FormatFactory.cpp index d7e9c33c822..082ccb85970 100644 --- a/src/Formats/FormatFactory.cpp +++ b/src/Formats/FormatFactory.cpp @@ -128,7 +128,6 @@ FormatSettings getFormatSettings(ContextPtr context, const Settings & settings) format_settings.pretty.max_rows = settings.output_format_pretty_max_rows; format_settings.pretty.max_value_width = settings.output_format_pretty_max_value_width; format_settings.pretty.output_format_pretty_row_numbers = settings.output_format_pretty_row_numbers; - format_settings.pretty.squash_milliseconds = static_cast(settings.output_format_pretty_squash_ms); format_settings.protobuf.input_flatten_google_wrappers = settings.input_format_protobuf_flatten_google_wrappers; format_settings.protobuf.output_nullables_with_google_wrappers = settings.output_format_protobuf_nullables_with_google_wrappers; format_settings.protobuf.skip_fields_with_unsupported_types_in_schema_inference = settings.input_format_protobuf_skip_fields_with_unsupported_types_in_schema_inference; diff --git a/src/Formats/FormatSettings.h b/src/Formats/FormatSettings.h index 3a2e818d540..b9a55ffaa83 100644 --- a/src/Formats/FormatSettings.h +++ b/src/Formats/FormatSettings.h @@ -227,7 +227,6 @@ struct FormatSettings UInt64 max_rows = 10000; UInt64 max_column_pad_width = 250; UInt64 max_value_width = 10000; - UInt64 squash_milliseconds = 100; bool color = true; bool output_format_pretty_row_numbers = false; diff --git a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp index bfcc4c101d9..14648e68f94 100644 --- a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp +++ b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp @@ -137,25 +137,21 @@ void PrettyBlockOutputFormat::write(Chunk chunk, PortKind port_kind) total_rows += chunk.getNumRows(); return; } - - if (mono_block - || (format_settings.pretty.squash_milliseconds - && time_after_previous_chunk.elapsedMilliseconds() <= format_settings.pretty.squash_milliseconds)) + if (mono_block) { if (port_kind == PortKind::Main) { - if (squashed_chunk) - squashed_chunk.append(chunk); + if (mono_chunk) + mono_chunk.append(chunk); else - squashed_chunk = std::move(chunk); + mono_chunk = std::move(chunk); return; } /// Should be written from writeSuffix() - assert(!squashed_chunk); + assert(!mono_chunk); } - writeSquashedChunkIfNeeded(); writeChunk(chunk, port_kind); } @@ -393,20 +389,18 @@ void PrettyBlockOutputFormat::consumeExtremes(Chunk chunk) } -void PrettyBlockOutputFormat::writeSquashedChunkIfNeeded() +void PrettyBlockOutputFormat::writeMonoChunkIfNeeded() { - if (squashed_chunk) + if (mono_chunk) { - writeChunk(squashed_chunk, PortKind::Main); - squashed_chunk.clear(); - if (format_settings.pretty.squash_milliseconds) - time_after_previous_chunk.restart(); + writeChunk(mono_chunk, PortKind::Main); + mono_chunk.clear(); } } void PrettyBlockOutputFormat::writeSuffix() { - writeSquashedChunkIfNeeded(); + writeMonoChunkIfNeeded(); if (total_rows >= format_settings.pretty.max_rows) { diff --git a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h index 621f1387196..dfb23ac63f9 100644 --- a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h +++ b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h @@ -39,7 +39,7 @@ protected: void write(Chunk chunk, PortKind port_kind); virtual void writeChunk(const Chunk & chunk, PortKind port_kind); - void writeSquashedChunkIfNeeded(); + void writeMonoChunkIfNeeded(); void writeSuffix() override; void onRowsReadBeforeUpdate() override { total_rows = getRowsReadBefore(); } @@ -59,11 +59,11 @@ protected: private: bool mono_block; - Chunk squashed_chunk; - Stopwatch time_after_previous_chunk; /// For squashing. + /// For mono_block == true only + Chunk mono_chunk; }; -template +template void registerPrettyFormatWithNoEscapesAndMonoBlock(FormatFactory & factory, const String & base_name) { auto creator = [&](FormatFactory & fact, const String & name, bool no_escapes, bool mono_block) @@ -81,6 +81,8 @@ void registerPrettyFormatWithNoEscapesAndMonoBlock(FormatFactory & factory, cons } return std::make_shared(buf, sample, format_settings, mono_block); }); + if (!mono_block) + factory.markOutputFormatSupportsParallelFormatting(name); }; creator(factory, base_name, false, false); creator(factory, base_name + "NoEscapes", true, false); diff --git a/src/Processors/Formats/Impl/PrettySpaceBlockOutputFormat.cpp b/src/Processors/Formats/Impl/PrettySpaceBlockOutputFormat.cpp index e54d88a11b2..0fb1a413a6c 100644 --- a/src/Processors/Formats/Impl/PrettySpaceBlockOutputFormat.cpp +++ b/src/Processors/Formats/Impl/PrettySpaceBlockOutputFormat.cpp @@ -100,7 +100,7 @@ void PrettySpaceBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port void PrettySpaceBlockOutputFormat::writeSuffix() { - writeSquashedChunkIfNeeded(); + writeMonoChunkIfNeeded(); if (total_rows >= format_settings.pretty.max_rows) { diff --git a/tests/queries/0_stateless/00098_k_union_all.sql b/tests/queries/0_stateless/00098_k_union_all.sql index 8f396d3479a..311e5bb19c4 100644 --- a/tests/queries/0_stateless/00098_k_union_all.sql +++ b/tests/queries/0_stateless/00098_k_union_all.sql @@ -1,4 +1,3 @@ -SET output_format_pretty_squash_ms = 0; SELECT 1 FORMAT PrettySpace; SELECT 1 UNION ALL SELECT 1 FORMAT PrettySpace; SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 FORMAT PrettySpace; diff --git a/tests/queries/0_stateless/00405_pretty_formats.sql b/tests/queries/0_stateless/00405_pretty_formats.sql index a7dc5aa0600..3c8af776278 100644 --- a/tests/queries/0_stateless/00405_pretty_formats.sql +++ b/tests/queries/0_stateless/00405_pretty_formats.sql @@ -1,5 +1,3 @@ -SET output_format_pretty_squash_ms = 0; - SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT Pretty; SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettyCompact; SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettySpace; diff --git a/tests/queries/0_stateless/00730_unicode_terminal_format.sql b/tests/queries/0_stateless/00730_unicode_terminal_format.sql index 6327b41a05a..b7a8084c406 100644 --- a/tests/queries/0_stateless/00730_unicode_terminal_format.sql +++ b/tests/queries/0_stateless/00730_unicode_terminal_format.sql @@ -1,7 +1,5 @@ DROP TABLE IF EXISTS unicode; -SET output_format_pretty_squash_ms = 0; - CREATE TABLE unicode(c1 String, c2 String) ENGINE = Memory; INSERT INTO unicode VALUES ('Здравствуйте', 'Этот код можно отредактировать и запустить!'); INSERT INTO unicode VALUES ('你好', '这段代码是可以编辑并且能够运行的!'); diff --git a/tests/queries/0_stateless/01065_window_view_event_hop_watch_bounded.py b/tests/queries/0_stateless/01065_window_view_event_hop_watch_bounded.py index 52d0c2c87d4..7f00130b184 100755 --- a/tests/queries/0_stateless/01065_window_view_event_hop_watch_bounded.py +++ b/tests/queries/0_stateless/01065_window_view_event_hop_watch_bounded.py @@ -19,17 +19,13 @@ with client(name="client1>", log=log) as client1, client( client1.expect(prompt) client2.expect(prompt) - client1.send( - "SET allow_experimental_analyzer = 0, output_format_pretty_squash_ms = 0;" - ) + client1.send("SET allow_experimental_analyzer = 0") client1.expect(prompt) client1.send("SET allow_experimental_window_view = 1") client1.expect(prompt) client1.send("SET window_view_heartbeat_interval = 1") client1.expect(prompt) - client2.send( - "SET allow_experimental_window_view = 1, output_format_pretty_squash_ms = 0;" - ) + client2.send("SET allow_experimental_window_view = 1") client2.expect(prompt) client1.send( diff --git a/tests/queries/0_stateless/01082_window_view_watch_limit.py b/tests/queries/0_stateless/01082_window_view_watch_limit.py index 07dbc232a63..12c8d295591 100755 --- a/tests/queries/0_stateless/01082_window_view_watch_limit.py +++ b/tests/queries/0_stateless/01082_window_view_watch_limit.py @@ -19,17 +19,13 @@ with client(name="client1>", log=log) as client1, client( client1.expect(prompt) client2.expect(prompt) - client1.send( - "SET allow_experimental_analyzer = 0, output_format_pretty_squash_ms = 0;" - ) + client1.send("SET allow_experimental_analyzer = 0") client1.expect(prompt) client1.send("SET allow_experimental_window_view = 1") client1.expect(prompt) client1.send("SET window_view_heartbeat_interval = 1") client1.expect(prompt) - client2.send( - "SET allow_experimental_window_view = 1, output_format_pretty_squash_ms = 0;" - ) + client2.send("SET allow_experimental_window_view = 1") client2.expect(prompt) client1.send("CREATE DATABASE IF NOT EXISTS 01082_window_view_watch_limit") diff --git a/tests/queries/0_stateless/01509_output_format_pretty_row_numbers.sql b/tests/queries/0_stateless/01509_output_format_pretty_row_numbers.sql index fb4c743d54b..f8ec0be74d7 100644 --- a/tests/queries/0_stateless/01509_output_format_pretty_row_numbers.sql +++ b/tests/queries/0_stateless/01509_output_format_pretty_row_numbers.sql @@ -1,5 +1,3 @@ -SET output_format_pretty_squash_ms = 0; - SELECT * FROM numbers(10) FORMAT Pretty; SELECT * FROM numbers(10) FORMAT PrettyCompact; SELECT * FROM numbers(10) FORMAT PrettyCompactMonoBlock; diff --git a/tests/queries/0_stateless/02122_parallel_formatting_Pretty.reference b/tests/queries/0_stateless/02122_parallel_formatting_Pretty.reference new file mode 100644 index 00000000000..72d346f82f7 --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_Pretty.reference @@ -0,0 +1,2 @@ +Pretty-1 +Pretty-2 diff --git a/tests/queries/0_stateless/02122_parallel_formatting_Pretty.sh b/tests/queries/0_stateless/02122_parallel_formatting_Pretty.sh new file mode 100755 index 00000000000..a72510b0614 --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_Pretty.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +${CUR_DIR}/02122_parallel_formatting.lib Pretty diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.reference b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.reference new file mode 100644 index 00000000000..35761b294db --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.reference @@ -0,0 +1,2 @@ +PrettyCompact-1 +PrettyCompact-2 diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.sh b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.sh new file mode 100755 index 00000000000..351f7ce0cd6 --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompact.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +${CUR_DIR}/02122_parallel_formatting.lib PrettyCompact diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.reference b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.reference new file mode 100644 index 00000000000..8b70c25b168 --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.reference @@ -0,0 +1,2 @@ +PrettyCompactNoEscapes-1 +PrettyCompactNoEscapes-2 diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.sh b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.sh new file mode 100755 index 00000000000..fd1e7a83ead --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettyCompactNoEscapes.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +${CUR_DIR}/02122_parallel_formatting.lib PrettyCompactNoEscapes diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.reference b/tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.reference new file mode 100644 index 00000000000..e2bfec67b7c --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.reference @@ -0,0 +1,2 @@ +PrettyNoEscapes-1 +PrettyNoEscapes-2 diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.sh b/tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.sh new file mode 100755 index 00000000000..20e6d9c6973 --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettyNoEscapes.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +${CUR_DIR}/02122_parallel_formatting.lib PrettyNoEscapes diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.reference b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.reference new file mode 100644 index 00000000000..fab8c8bde76 --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.reference @@ -0,0 +1,2 @@ +PrettySpace-1 +PrettySpace-2 diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.sh b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.sh new file mode 100755 index 00000000000..8af990d9113 --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpace.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +${CUR_DIR}/02122_parallel_formatting.lib PrettySpace diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.reference b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.reference new file mode 100644 index 00000000000..154ee87e82a --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.reference @@ -0,0 +1,2 @@ +PrettySpaceNoEscapes-1 +PrettySpaceNoEscapes-2 diff --git a/tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.sh b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.sh new file mode 100755 index 00000000000..8fcbfbc16cf --- /dev/null +++ b/tests/queries/0_stateless/02122_parallel_formatting_PrettySpaceNoEscapes.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Tags: no-fasttest + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +${CUR_DIR}/02122_parallel_formatting.lib PrettySpaceNoEscapes diff --git a/tests/queries/0_stateless/02375_pretty_formats.sql.j2 b/tests/queries/0_stateless/02375_pretty_formats.sql.j2 index 92e0a357138..cc61346d267 100644 --- a/tests/queries/0_stateless/02375_pretty_formats.sql.j2 +++ b/tests/queries/0_stateless/02375_pretty_formats.sql.j2 @@ -3,7 +3,6 @@ 'PrettySpaceNoEscapesMonoBlock'] -%} select '{{ format }}'; -SET output_format_pretty_squash_ms = 0; select number as x, number + 1 as y from numbers(4) settings max_block_size=2 format {{ format }}; {% endfor -%} diff --git a/tests/queries/0_stateless/02731_pretty_time_based_squashing.reference b/tests/queries/0_stateless/02731_pretty_time_based_squashing.reference deleted file mode 100644 index 653faf33a46..00000000000 --- a/tests/queries/0_stateless/02731_pretty_time_based_squashing.reference +++ /dev/null @@ -1,14 +0,0 @@ -┌─number─┐ -│ 0 │ -└────────┘ -┌─number─┐ -│ 1 │ -└────────┘ -┌─number─┐ -│ 2 │ -└────────┘ -┌─number─┐ -│ 0 │ -│ 1 │ -│ 2 │ -└────────┘ diff --git a/tests/queries/0_stateless/02731_pretty_time_based_squashing.sql b/tests/queries/0_stateless/02731_pretty_time_based_squashing.sql deleted file mode 100644 index e5656c8e1ca..00000000000 --- a/tests/queries/0_stateless/02731_pretty_time_based_squashing.sql +++ /dev/null @@ -1,2 +0,0 @@ -SELECT * FROM numbers(3) FORMAT PrettyCompact SETTINGS max_block_size = 1, max_threads = 1, output_format_pretty_squash_ms = 0; -SELECT * FROM numbers(3) FORMAT PrettyCompact SETTINGS max_block_size = 1, max_threads = 1, output_format_pretty_squash_ms = 600_000;