Skip to content

Commit

Permalink
Merge pull request #61791 from ClickHouse/enable-output_format_pretty…
Browse files Browse the repository at this point in the history
…_row_numbers

Enable `output_format_pretty_row_numbers` by default
  • Loading branch information
alexey-milovidov committed Mar 25, 2024
2 parents 447d202 + 06a9ac7 commit 0d1751f
Show file tree
Hide file tree
Showing 56 changed files with 2,160 additions and 2,138 deletions.
2 changes: 1 addition & 1 deletion src/Core/Settings.h
Expand Up @@ -1140,7 +1140,7 @@ class IColumn;
\
M(Bool, output_format_enable_streaming, false, "Enable streaming in output formats that support it.", 0) \
M(Bool, output_format_write_statistics, true, "Write statistics about read rows, bytes, time elapsed in suitable output formats.", 0) \
M(Bool, output_format_pretty_row_numbers, false, "Add row numbers before each row for pretty output format", 0) \
M(Bool, output_format_pretty_row_numbers, true, "Add row numbers before each row for pretty output format", 0) \
M(Bool, output_format_pretty_highlight_digit_groups, true, "If enabled and if output is a terminal, highlight every digit corresponding to the number of thousands, millions, etc. with underline.", 0) \
M(UInt64, output_format_pretty_single_large_number_tip_threshold, 1'000'000, "Print a readable number tip on the right side of the table if the block consists of a single number which exceeds this value (except 0)", 0) \
M(Bool, insert_distributed_one_random_shard, false, "If setting is enabled, inserting into distributed table will choose a random shard to write when there is no sharding key", 0) \
Expand Down
1 change: 1 addition & 0 deletions src/Core/SettingsChangesHistory.h
Expand Up @@ -106,6 +106,7 @@ static std::map<ClickHouseVersion, SettingsChangesHistory::SettingsChanges> sett
{"keeper_retry_max_backoff_ms", 5000, 5000, "Max backoff timeout for general keeper operations"},
{"s3queue_allow_experimental_sharded_mode", false, false, "Enable experimental sharded mode of S3Queue table engine. It is experimental because it will be rewritten"},
{"merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability", 0.0, 0.0, "For testing of `PartsSplitter` - split read ranges into intersecting and non intersecting every time you read from MergeTree with the specified probability."},
{"output_format_pretty_row_numbers", false, true, "It is better for usability."},
{"output_format_pretty_max_value_width_apply_for_single_value", true, false, "Single values in Pretty formats won't be cut."},
{"output_format_parquet_string_as_string", false, true, "ClickHouse allows arbitrary binary data in the String data type, which is typically UTF-8. Parquet/ORC/Arrow Strings only support UTF-8. That's why you can choose which Arrow's data type to use for the ClickHouse String data type - String or Binary. While Binary would be more correct and compatible, using String by default will correspond to user expectations in most cases."},
{"output_format_orc_string_as_string", false, true, "ClickHouse allows arbitrary binary data in the String data type, which is typically UTF-8. Parquet/ORC/Arrow Strings only support UTF-8. That's why you can choose which Arrow's data type to use for the ClickHouse String data type - String or Binary. While Binary would be more correct and compatible, using String by default will correspond to user expectations in most cases."},
Expand Down
9 changes: 6 additions & 3 deletions src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp
Expand Up @@ -291,11 +291,14 @@ void PrettyBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port_kind
{
// Write row number;
auto row_num_string = std::to_string(i + 1 + total_rows) + ". ";

for (size_t j = 0; j < row_number_width - row_num_string.size(); ++j)
{
writeCString(" ", out);
}
writeChar(' ', out);
if (color)
writeCString("\033[90m", out);
writeString(row_num_string, out);
if (color)
writeCString("\033[0m", out);
}

writeCString(grid_symbols.bar, out);
Expand Down
Expand Up @@ -147,10 +147,12 @@ void PrettyCompactBlockOutputFormat::writeRow(
// Write row number;
auto row_num_string = std::to_string(row_num + 1 + total_rows) + ". ";
for (size_t i = 0; i < row_number_width - row_num_string.size(); ++i)
{
writeCString(" ", out);
}
writeChar(' ', out);
if (color)
writeCString("\033[90m", out);
writeString(row_num_string, out);
if (color)
writeCString("\033[0m", out);
}

const GridSymbols & grid_symbols = format_settings.pretty.charset == FormatSettings::Pretty::Charset::UTF8 ?
Expand Down
7 changes: 6 additions & 1 deletion src/Processors/Formats/Impl/PrettySpaceBlockOutputFormat.cpp
Expand Up @@ -77,8 +77,13 @@ void PrettySpaceBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port
// Write row number;
auto row_num_string = std::to_string(row + 1 + total_rows) + ". ";
for (size_t i = 0; i < row_number_width - row_num_string.size(); ++i)
writeCString(" ", out);
writeChar(' ', out);
if (color)
writeCString("\033[90m", out);
writeString(row_num_string, out);
if (color)
writeCString("\033[0m", out);

}
for (size_t column = 0; column < num_columns; ++column)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_storage_kafka/test.py
Expand Up @@ -4452,7 +4452,7 @@ def test_block_based_formats_1(kafka_cluster):
kafka_group_name = '{topic}',
kafka_format = 'PrettySpace';
INSERT INTO test.kafka SELECT number * 10 as key, number * 100 as value FROM numbers(5) settings max_block_size=2, optimize_trivial_insert_select=0, output_format_pretty_color=1;
INSERT INTO test.kafka SELECT number * 10 as key, number * 100 as value FROM numbers(5) settings max_block_size=2, optimize_trivial_insert_select=0, output_format_pretty_color=1, output_format_pretty_row_numbers=0;
"""
)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_storage_rabbitmq/test.py
Expand Up @@ -3202,7 +3202,7 @@ def test_block_based_formats_1(rabbitmq_cluster):
)

instance.query(
"INSERT INTO test.rabbitmq SELECT number * 10 as key, number * 100 as value FROM numbers(5) settings max_block_size=2, optimize_trivial_insert_select=0, output_format_pretty_color=1;"
"INSERT INTO test.rabbitmq SELECT number * 10 as key, number * 100 as value FROM numbers(5) settings max_block_size=2, optimize_trivial_insert_select=0, output_format_pretty_color=1, output_format_pretty_row_numbers=0;"
)
insert_messages = []

Expand Down
@@ -1,3 +1,3 @@
┌─x───────────────────────────┐
│ ('2000-01-01','2000-01-01') │
└─────────────────────────────┘
┌─x───────────────────────────┐
1. │ ('2000-01-01','2000-01-01') │
└─────────────────────────────┘
24 changes: 12 additions & 12 deletions tests/queries/0_stateless/00098_k_union_all.reference
@@ -1,18 +1,18 @@
1
1

1
1
1.  1
1

1
1
1.  1
1

1
1
2.  1
1

1
1
1.  1
1

1
1
2.  1
1

1
3.  1
34 changes: 17 additions & 17 deletions tests/queries/0_stateless/00298_enum_width_and_cast.reference
@@ -1,17 +1,17 @@
┌─x─────┬─y─┐
│ Hello │ 0 │
└───────┴───┘
┌─x─────┬─y─┐
│ Hello │ 0 │
│ \ │ 0 │
└───────┴───┘
┌─x────────┬─y─┐
│ Hello │ 0 │
│ \ │ 0 │
│ \t │ 0 │
└──────────┴───┘
┌─x────────┬─y─┬─toInt8(x)─┬─s─────┬─casted─┐
│ Hello │ 0 │ -100 │ Hello │ Hello │
│ \ │ 0 │ 0 │ \ │ \ │
│ \t │ 0 │ 111 │ \t │ \t │
└──────────┴───┴───────────┴───────┴────────┘
┌─x─────┬─y─┐
1. │ Hello │ 0 │
└───────┴───┘
┌─x─────┬─y─┐
1. │ Hello │ 0 │
2. │ \ │ 0 │
└───────┴───┘
┌─x────────┬─y─┐
1. │ Hello │ 0 │
2. │ \ │ 0 │
3. │ \t │ 0 │
└──────────┴───┘
┌─x────────┬─y─┬─toInt8(x)─┬─s─────┬─casted─┐
1. │ Hello │ 0 │ -100 │ Hello │ Hello │
2. │ \ │ 0 │ 0 │ \ │ \ │
3. │ \t │ 0 │ 111 │ \t │ \t │
└──────────┴───┴───────────┴───────┴────────┘
24 changes: 12 additions & 12 deletions tests/queries/0_stateless/00305_http_and_readonly.reference
@@ -1,19 +1,19 @@
name value changed
name value changed

max_rows_to_read 10000 1
readonly 0 0
name value changed
1. max_rows_to_read 10000 1
2. readonly 0 0
name value changed

max_rows_to_read 10000 1
readonly 2 1
name value changed
1. max_rows_to_read 10000 1
2. readonly 2 1
name value changed

max_rows_to_read 10000 1
readonly 1 1
name value changed
1. max_rows_to_read 10000 1
2. readonly 1 1
name value changed

max_rows_to_read 10000 1
readonly 2 1
1. max_rows_to_read 10000 1
2. readonly 2 1
Ok
Ok
0
Expand Down
@@ -1,3 +1,3 @@
┌─x─────────┬─y───────────┐
│ ['hello'] │ (1,'hello') │
└───────────┴─────────────┘
┌─x─────────┬─y───────────┐
1. │ ['hello'] │ (1,'hello') │
└───────────┴─────────────┘
48 changes: 24 additions & 24 deletions tests/queries/0_stateless/00405_PrettyCompactMonoBlock.reference
@@ -1,32 +1,32 @@
one block
┌─number─┐
│ 0 │
│ 1 │
└────────┘
┌─number─┐
1. │ 0 │
2. │ 1 │
└────────┘
two blocks
┌─number─┐
│ 0 │
│ 0 │
└────────┘
┌─number─┐
1. │ 0 │
2. │ 0 │
└────────┘
extremes
┌─number─┐
│ 0 │
│ 1 │
│ 2 │
└────────┘
┌─number─┐
1. │ 0 │
2. │ 1 │
3. │ 2 │
└────────┘

Extremes:
┌─number─┐
│ 0 │
│ 2 │
└────────┘
┌─number─┐
1. │ 0 │
2. │ 2 │
└────────┘
totals
┌─sum(number)─┐
│ 2 │
│ 1 │
└─────────────┘
┌─sum(number)─┐
1. │ 2 │
2. │ 1 │
└─────────────┘

Totals:
┌─sum(number)─┐
│ 3 │
└─────────────┘
┌─sum(number)─┐
1. │ 3 │
└─────────────┘

0 comments on commit 0d1751f

Please sign in to comment.