mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Revert "Merge pull request #63493 from Volodyachan/fix-tabs-in-pretty-format"
This reverts commit8ed245677d
, reversing changes made to7be88cca1f
.
This commit is contained in:
parent
a2223f6ec5
commit
610801f1be
@ -24,7 +24,7 @@ PrettyBlockOutputFormat::PrettyBlockOutputFormat(
|
||||
/// Note that number of code points is just a rough approximation of visible string width.
|
||||
void PrettyBlockOutputFormat::calculateWidths(
|
||||
const Block & header, const Chunk & chunk,
|
||||
WidthsPerColumn & widths, Widths & max_padded_widths, Widths & name_widths, size_t table_border_width)
|
||||
WidthsPerColumn & widths, Widths & max_padded_widths, Widths & name_widths)
|
||||
{
|
||||
size_t num_rows = std::min(chunk.getNumRows(), format_settings.pretty.max_rows);
|
||||
|
||||
@ -42,7 +42,7 @@ void PrettyBlockOutputFormat::calculateWidths(
|
||||
|
||||
/// Calculate widths of all values.
|
||||
String serialized_value;
|
||||
size_t prefix = format_settings.pretty.output_format_pretty_row_numbers ? row_number_width + table_border_width : table_border_width; // Tab character adjustment
|
||||
size_t prefix = 2; // Tab character adjustment
|
||||
for (size_t i = 0; i < num_columns; ++i)
|
||||
{
|
||||
const auto & elem = header.getByPosition(i);
|
||||
@ -187,7 +187,7 @@ void PrettyBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port_kind
|
||||
WidthsPerColumn widths;
|
||||
Widths max_widths;
|
||||
Widths name_widths;
|
||||
calculateWidths(header, chunk, widths, max_widths, name_widths, 2);
|
||||
calculateWidths(header, chunk, widths, max_widths, name_widths);
|
||||
|
||||
const GridSymbols & grid_symbols = format_settings.pretty.charset == FormatSettings::Pretty::Charset::UTF8 ?
|
||||
utf8_grid_symbols :
|
||||
@ -321,7 +321,6 @@ void PrettyBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port_kind
|
||||
|
||||
std::vector<String> transferred_row(num_columns);
|
||||
bool has_transferred_row = false;
|
||||
size_t prefix = format_settings.pretty.output_format_pretty_row_numbers ? row_number_width + 2 : 2;
|
||||
|
||||
for (size_t j = 0; j < num_columns; ++j)
|
||||
{
|
||||
@ -335,13 +334,11 @@ void PrettyBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port_kind
|
||||
serializations[j]->serializeText(*columns[j], i, out_serialize, format_settings);
|
||||
}
|
||||
if (cut_to_width && format_settings.pretty.preserve_border_for_multiline_string)
|
||||
splitValueAtBreakLine(serialized_value, transferred_row[j], cur_width, cut_to_width, prefix);
|
||||
has_transferred_row |= !transferred_row[j].empty();
|
||||
splitValueAtBreakLine(serialized_value, transferred_row[j], cur_width);
|
||||
has_transferred_row |= !transferred_row[j].empty() && cur_width <= cut_to_width;
|
||||
|
||||
writeValueWithPadding(serialized_value, cur_width, max_widths[j], cut_to_width,
|
||||
type.shouldAlignRightInPrettyFormats(), isNumber(type), !transferred_row[j].empty(), false);
|
||||
|
||||
prefix += max_widths[j] + 3;
|
||||
}
|
||||
|
||||
writeCString(grid_symbols.bar, out);
|
||||
@ -502,7 +499,6 @@ void PrettyBlockOutputFormat::writeTransferredRow(const Widths & max_widths, con
|
||||
|
||||
std::vector<String> new_transferred_row(num_columns);
|
||||
bool has_transferred_row = false;
|
||||
size_t prefix = format_settings.pretty.output_format_pretty_row_numbers ? row_number_width + 2 : 2;
|
||||
|
||||
for (size_t j = 0; j < num_columns; ++j)
|
||||
{
|
||||
@ -514,13 +510,11 @@ void PrettyBlockOutputFormat::writeTransferredRow(const Widths & max_widths, con
|
||||
const auto & type = *header.getByPosition(j).type;
|
||||
size_t cur_width = UTF8::computeWidth(reinterpret_cast<const UInt8 *>(transferred_row[j].data()), transferred_row[j].size());
|
||||
if (cut_to_width)
|
||||
splitValueAtBreakLine(transferred_row[j], new_transferred_row[j], cur_width, cut_to_width, prefix);
|
||||
has_transferred_row |= !new_transferred_row[j].empty();
|
||||
splitValueAtBreakLine(transferred_row[j], new_transferred_row[j], cur_width);
|
||||
has_transferred_row |= !new_transferred_row[j].empty() && cur_width <= cut_to_width;
|
||||
|
||||
writeValueWithPadding(transferred_row[j], cur_width, max_widths[j], cut_to_width,
|
||||
type.shouldAlignRightInPrettyFormats(), isNumber(type), !new_transferred_row[j].empty(), !transferred_row[j].empty());
|
||||
|
||||
prefix += max_widths[j] + 3;
|
||||
}
|
||||
|
||||
if (!space_block)
|
||||
@ -531,14 +525,13 @@ void PrettyBlockOutputFormat::writeTransferredRow(const Widths & max_widths, con
|
||||
writeTransferredRow(max_widths, header, new_transferred_row, cut_to_width, space_block);
|
||||
}
|
||||
|
||||
void PrettyBlockOutputFormat::splitValueAtBreakLine(String & value, String & transferred_value, size_t & value_width, size_t cut_to_width, size_t prefix)
|
||||
void PrettyBlockOutputFormat::splitValueAtBreakLine(String & value, String & transferred_value, size_t & value_width)
|
||||
{
|
||||
if (size_t break_line_pos = value.find_first_of('\n'); break_line_pos != String::npos)
|
||||
{
|
||||
value_width = UTF8::computeWidth(reinterpret_cast<const UInt8 *>(value.data()), break_line_pos, prefix);
|
||||
if (value_width <= cut_to_width)
|
||||
transferred_value = value.substr(break_line_pos + 1);
|
||||
transferred_value = value.substr(break_line_pos + 1);
|
||||
value = value.substr(0, break_line_pos);
|
||||
value_width = UTF8::computeWidth(reinterpret_cast<const UInt8 *>(value.data()), value.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
|
||||
void calculateWidths(
|
||||
const Block & header, const Chunk & chunk,
|
||||
WidthsPerColumn & widths, Widths & max_padded_widths, Widths & name_widths, size_t table_border_width);
|
||||
WidthsPerColumn & widths, Widths & max_padded_widths, Widths & name_widths);
|
||||
|
||||
void writeValueWithPadding(
|
||||
String & value, size_t value_width, size_t pad_to_width, size_t cut_to_width,
|
||||
@ -52,7 +52,7 @@ protected:
|
||||
|
||||
void writeTransferredRow(const Widths & max_widths, const Block & header, std::vector<String> & transferred_row, size_t cut_to_width, bool space_block);
|
||||
|
||||
void splitValueAtBreakLine(String & value, String & transferred_value, size_t & value_width, size_t cut_to_width, size_t prefix);
|
||||
void splitValueAtBreakLine(String & value, String & transferred_value, size_t & value_width);
|
||||
|
||||
void resetFormatterImpl() override
|
||||
{
|
||||
|
@ -170,8 +170,6 @@ void PrettyCompactBlockOutputFormat::writeRow(
|
||||
|
||||
std::vector<String> transferred_row(num_columns);
|
||||
bool has_transferred_row = false;
|
||||
size_t prefix = format_settings.pretty.output_format_pretty_row_numbers ? row_number_width + 2 : 2;
|
||||
|
||||
for (size_t j = 0; j < num_columns; ++j)
|
||||
{
|
||||
if (j != 0)
|
||||
@ -185,13 +183,11 @@ void PrettyCompactBlockOutputFormat::writeRow(
|
||||
serializations[j]->serializeText(*columns[j], row_num, out_serialize, format_settings);
|
||||
}
|
||||
if (cut_to_width && format_settings.pretty.preserve_border_for_multiline_string)
|
||||
splitValueAtBreakLine(serialized_value, transferred_row[j], cur_width, cut_to_width, prefix);
|
||||
has_transferred_row |= !transferred_row[j].empty();
|
||||
splitValueAtBreakLine(serialized_value, transferred_row[j], cur_width);
|
||||
has_transferred_row |= !transferred_row[j].empty() && cur_width <= cut_to_width;
|
||||
|
||||
writeValueWithPadding(serialized_value, cur_width, max_widths[j], cut_to_width,
|
||||
type.shouldAlignRightInPrettyFormats(), isNumber(type), !transferred_row[j].empty(), false);
|
||||
|
||||
prefix += max_widths[j] + 3;
|
||||
}
|
||||
|
||||
writeCString(grid_symbols.bar, out);
|
||||
@ -212,7 +208,7 @@ void PrettyCompactBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind po
|
||||
WidthsPerColumn widths;
|
||||
Widths max_widths;
|
||||
Widths name_widths;
|
||||
calculateWidths(header, chunk, widths, max_widths, name_widths, 2);
|
||||
calculateWidths(header, chunk, widths, max_widths, name_widths);
|
||||
|
||||
writeHeader(header, max_widths, name_widths);
|
||||
|
||||
|
@ -31,7 +31,7 @@ void PrettySpaceBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port
|
||||
WidthsPerColumn widths;
|
||||
Widths max_widths;
|
||||
Widths name_widths;
|
||||
calculateWidths(header, chunk, widths, max_widths, name_widths, 1);
|
||||
calculateWidths(header, chunk, widths, max_widths, name_widths);
|
||||
|
||||
if (format_settings.pretty.output_format_pretty_row_numbers)
|
||||
writeString(String(row_number_width, ' '), out);
|
||||
@ -88,7 +88,6 @@ void PrettySpaceBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port
|
||||
writeCString("\033[0m", out);
|
||||
|
||||
}
|
||||
size_t prefix = format_settings.pretty.output_format_pretty_row_numbers ? row_number_width + 1 : 1;
|
||||
for (size_t column = 0; column < num_columns; ++column)
|
||||
{
|
||||
if (column != 0)
|
||||
@ -102,13 +101,11 @@ void PrettySpaceBlockOutputFormat::writeChunk(const Chunk & chunk, PortKind port
|
||||
serializations[column]->serializeText(*columns[column], row, out_serialize, format_settings);
|
||||
}
|
||||
if (cut_to_width && format_settings.pretty.preserve_border_for_multiline_string)
|
||||
splitValueAtBreakLine(serialized_value, transferred_row[column], cur_width, cur_width, prefix);
|
||||
has_transferred_row |= !transferred_row[column].empty();
|
||||
splitValueAtBreakLine(serialized_value, transferred_row[column], cur_width);
|
||||
has_transferred_row |= !transferred_row[column].empty() && cur_width <= cut_to_width;
|
||||
|
||||
writeValueWithPadding(serialized_value, cur_width, max_widths[column], cut_to_width,
|
||||
type.shouldAlignRightInPrettyFormats(), isNumber(type), !transferred_row[column].empty(), false);
|
||||
|
||||
prefix += max_widths[column] + 3;
|
||||
}
|
||||
|
||||
writeReadableNumberTip(chunk);
|
||||
|
@ -5,13 +5,13 @@
|
||||
[90m1. [0m│ Hello │ 0 │
|
||||
[90m2. [0m│ \ │ 0 │
|
||||
└───────┴───┘
|
||||
┌─[1mx[0m─────┬─[1my[0m─┐
|
||||
[90m1. [0m│ Hello │ 0 │
|
||||
[90m2. [0m│ \ │ 0 │
|
||||
┌─[1mx[0m────────┬─[1my[0m─┐
|
||||
[90m1. [0m│ Hello │ 0 │
|
||||
[90m2. [0m│ \ │ 0 │
|
||||
[90m3. [0m│ \t │ 0 │
|
||||
└───────┴───┘
|
||||
┌─[1mx[0m─────┬─[1my[0m─┬─[1mtoInt8(x)[0m─┬─[1ms[0m─────┬─[1mcasted[0m─┐
|
||||
[90m1. [0m│ Hello │ 0 │ -100 │ Hello │ Hello │
|
||||
[90m2. [0m│ \ │ 0 │ 0 │ \ │ \ │
|
||||
└──────────┴───┘
|
||||
┌─[1mx[0m────────┬─[1my[0m─┬─[1mtoInt8(x)[0m─┬─[1ms[0m─────┬─[1mcasted[0m─┐
|
||||
[90m1. [0m│ Hello │ 0 │ -100 │ Hello │ Hello │
|
||||
[90m2. [0m│ \ │ 0 │ 0 │ \ │ \ │
|
||||
[90m3. [0m│ \t │ 0 │ 111 │ \t │ \t │
|
||||
└───────┴───┴───────────┴───────┴────────┘
|
||||
└──────────┴───┴───────────┴───────┴────────┘
|
||||
|
@ -63,11 +63,11 @@
|
||||
┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
||||
13. │ Ahoj │ Tento kód můžete upravit a spustit │
|
||||
└──────┴────────────────────────────────────┘
|
||||
┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ c1 ┃ c2 ┃
|
||||
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
|
||||
┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ c1 ┃ c2 ┃
|
||||
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
|
||||
14. │ Tabs Tabs │ Non-first Tabs │
|
||||
└─────────────────┴───────────────────────┘
|
||||
└─────────────┴───────────────────────┘
|
||||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ c1 ┃ c2 ┃
|
||||
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
||||
@ -78,11 +78,11 @@
|
||||
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
|
||||
16. │ Russian ё and ё │ Zero bytes |