mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
commit
8820b43606
@ -1,5 +1,6 @@
|
||||
#include <Processors/Formats/Impl/MarkdownRowOutputFormat.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <DataTypes/IDataType.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -12,34 +13,41 @@ void MarkdownRowOutputFormat::writePrefix()
|
||||
const auto & header = getPort(PortKind::Main).getHeader();
|
||||
size_t columns = header.columns();
|
||||
|
||||
writeChar('|', out);
|
||||
writeCString("| ", out);
|
||||
for (size_t i = 0; i < columns; ++i)
|
||||
{
|
||||
writeEscapedString(header.safeGetByPosition(i).name, out);
|
||||
writeChar('|', out);
|
||||
writeCString(" | ", out);
|
||||
}
|
||||
writeCString("\n|", out);
|
||||
String format = ":-:|";
|
||||
String left_alignment = ":-|";
|
||||
String central_alignment = ":-:|";
|
||||
String right_alignment = "-:|";
|
||||
for (size_t i = 0; i < columns; ++i)
|
||||
{
|
||||
writeString(format, out);
|
||||
if (isInteger(types[i]))
|
||||
writeString(right_alignment, out);
|
||||
else if (isString(types[i]))
|
||||
writeString(left_alignment, out);
|
||||
else
|
||||
writeString(central_alignment, out);
|
||||
}
|
||||
writeChar('\n', out);
|
||||
}
|
||||
|
||||
void MarkdownRowOutputFormat::writeRowStartDelimiter()
|
||||
{
|
||||
writeChar('|', out);
|
||||
writeCString("| ", out);
|
||||
}
|
||||
|
||||
void MarkdownRowOutputFormat::writeFieldDelimiter()
|
||||
{
|
||||
writeChar('|', out);
|
||||
writeCString(" | ", out);
|
||||
}
|
||||
|
||||
void MarkdownRowOutputFormat::writeRowEndDelimiter()
|
||||
{
|
||||
writeCString("|\n", out);
|
||||
writeCString(" |\n", out);
|
||||
}
|
||||
|
||||
void MarkdownRowOutputFormat::writeField(const IColumn & column, const IDataType & type, size_t row_num)
|
||||
|
@ -1,5 +1,5 @@
|
||||
|id|name|array|
|
||||
|:-:|:-:|:-:|
|
||||
|1|name1|[1,2,3]|
|
||||
|2|name2|[4,5,6]|
|
||||
|3|name3|[7,8,9]|
|
||||
| id | name | array |
|
||||
|-:|:-|:-:|
|
||||
| 1 | name1 | [1,2,3] |
|
||||
| 2 | name2 | [4,5,6] |
|
||||
| 3 | name3 | [7,8,9] |
|
||||
|
Loading…
Reference in New Issue
Block a user