Merge pull request #49850 from ClickHouse/revert-49537-pretty-time-squashing

Revert "Make `Pretty` formats even prettier."
This commit is contained in:
Alexey Milovidov 2023-05-13 04:19:15 +03:00 committed by GitHub
commit b18b1868f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 63 additions and 60 deletions

View File

@ -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) \

View File

@ -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<UInt64>(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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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 <typename OutputFormat>
template <class OutputFormat>
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<OutputFormat>(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);

View File

@ -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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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 ('你好', '这段代码是可以编辑并且能够运行的!');

View File

@ -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(

View File

@ -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")

View File

@ -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;

View File

@ -0,0 +1,2 @@
Pretty-1
Pretty-2

View File

@ -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

View File

@ -0,0 +1,2 @@
PrettyCompact-1
PrettyCompact-2

View File

@ -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

View File

@ -0,0 +1,2 @@
PrettyCompactNoEscapes-1
PrettyCompactNoEscapes-2

View File

@ -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

View File

@ -0,0 +1,2 @@
PrettyNoEscapes-1
PrettyNoEscapes-2

View File

@ -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

View File

@ -0,0 +1,2 @@
PrettySpace-1
PrettySpace-2

View File

@ -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

View File

@ -0,0 +1,2 @@
PrettySpaceNoEscapes-1
PrettySpaceNoEscapes-2

View File

@ -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

View File

@ -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 -%}

View File

@ -1,14 +0,0 @@
┌─number─┐
│ 0 │
└────────┘
┌─number─┐
│ 1 │
└────────┘
┌─number─┐
│ 2 │
└────────┘
┌─number─┐
│ 0 │
│ 1 │
│ 2 │
└────────┘

View File

@ -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;