Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
831c48c5
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
831c48c5
编写于
4月 16, 2020
作者:
A
Avogar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add MarkdownRowOutput format
上级
23ae3f4b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
114 addition
and
0 deletion
+114
-0
src/Formats/FormatFactory.cpp
src/Formats/FormatFactory.cpp
+1
-0
src/Formats/FormatFactory.h
src/Formats/FormatFactory.h
+1
-0
src/Processors/Formats/Impl/MarkdownRowOutputFormat.cpp
src/Processors/Formats/Impl/MarkdownRowOutputFormat.cpp
+62
-0
src/Processors/Formats/Impl/MarkdownRowOutputFormat.h
src/Processors/Formats/Impl/MarkdownRowOutputFormat.h
+39
-0
tests/queries/0_stateless/01231_markdown_format.reference
tests/queries/0_stateless/01231_markdown_format.reference
+5
-0
tests/queries/0_stateless/01231_markdown_format.sql
tests/queries/0_stateless/01231_markdown_format.sql
+6
-0
未找到文件。
src/Formats/FormatFactory.cpp
浏览文件 @
831c48c5
...
...
@@ -377,6 +377,7 @@ FormatFactory::FormatFactory()
registerOutputFormatProcessorODBCDriver2
(
*
this
);
registerOutputFormatProcessorNull
(
*
this
);
registerOutputFormatProcessorMySQLWrite
(
*
this
);
registerOutputFormatProcessorMarkdown
(
*
this
);
}
FormatFactory
&
FormatFactory
::
instance
()
...
...
src/Formats/FormatFactory.h
浏览文件 @
831c48c5
...
...
@@ -198,6 +198,7 @@ void registerOutputFormatProcessorODBCDriver(FormatFactory & factory);
void
registerOutputFormatProcessorODBCDriver2
(
FormatFactory
&
factory
);
void
registerOutputFormatProcessorNull
(
FormatFactory
&
factory
);
void
registerOutputFormatProcessorMySQLWrite
(
FormatFactory
&
factory
);
void
registerOutputFormatProcessorMarkdown
(
FormatFactory
&
factory
);
/// Input only formats.
void
registerInputFormatProcessorCapnProto
(
FormatFactory
&
factory
);
...
...
src/Processors/Formats/Impl/MarkdownRowOutputFormat.cpp
0 → 100644
浏览文件 @
831c48c5
#include <Processors/Formats/Impl/MarkdownRowOutputFormat.h>
#include <IO/WriteHelpers.h>
namespace
DB
{
MarkdownRowOutputFormat
::
MarkdownRowOutputFormat
(
WriteBuffer
&
out_
,
const
Block
&
header_
,
FormatFactory
::
WriteCallback
callback
,
const
FormatSettings
&
format_settings_
)
:
IRowOutputFormat
(
header_
,
out_
,
callback
),
format_settings
(
format_settings_
)
{}
void
MarkdownRowOutputFormat
::
writePrefix
()
{
auto
&
header
=
getPort
(
PortKind
::
Main
).
getHeader
();
size_t
columns
=
header
.
columns
();
writeChar
(
'|'
,
out
);
for
(
size_t
i
=
0
;
i
<
columns
;
++
i
)
{
writeEscapedString
(
header
.
safeGetByPosition
(
i
).
name
,
out
);
writeChar
(
'|'
,
out
);
}
writeCString
(
"
\n
|"
,
out
);
String
format
=
":-:|"
;
for
(
size_t
i
=
0
;
i
<
columns
;
++
i
)
{
writeString
(
format
,
out
);
}
writeChar
(
'\n'
,
out
);
}
void
MarkdownRowOutputFormat
::
writeRowStartDelimiter
()
{
writeChar
(
'|'
,
out
);
}
void
MarkdownRowOutputFormat
::
writeFieldDelimiter
()
{
writeChar
(
'|'
,
out
);
}
void
MarkdownRowOutputFormat
::
writeRowEndDelimiter
()
{
writeCString
(
"|
\n
"
,
out
);
}
void
MarkdownRowOutputFormat
::
writeField
(
const
IColumn
&
column
,
const
IDataType
&
type
,
size_t
row_num
)
{
type
.
serializeAsTextEscaped
(
column
,
row_num
,
out
,
format_settings
);
}
void
registerOutputFormatProcessorMarkdown
(
FormatFactory
&
factory
)
{
factory
.
registerOutputFormatProcessor
(
"Markdown"
,
[](
WriteBuffer
&
buf
,
const
Block
&
sample
,
FormatFactory
::
WriteCallback
callback
,
const
FormatSettings
&
settings
)
{
return
std
::
make_shared
<
MarkdownRowOutputFormat
>
(
buf
,
sample
,
callback
,
settings
);
});
}
}
\ No newline at end of file
src/Processors/Formats/Impl/MarkdownRowOutputFormat.h
0 → 100644
浏览文件 @
831c48c5
#pragma once
#include <Processors/Formats/IRowOutputFormat.h>
#include <Formats/FormatFactory.h>
#include <Formats/FormatSettings.h>
namespace
DB
{
class
ReadBuffer
;
class
MarkdownRowOutputFormat
:
public
IRowOutputFormat
{
public:
MarkdownRowOutputFormat
(
WriteBuffer
&
out_
,
const
Block
&
header_
,
FormatFactory
::
WriteCallback
callback
,
const
FormatSettings
&
format_settings_
);
/// Write higher part of markdown table like this:
/// |columnName1|columnName2|...|columnNameN|
/// |:-:|:-:|...|:-:|
void
writePrefix
()
override
;
/// Write '|' before each row
void
writeRowStartDelimiter
()
override
;
/// Write '|' between values
void
writeFieldDelimiter
()
override
;
/// Write '|\n' after each row
void
writeRowEndDelimiter
()
override
;
void
writeField
(
const
IColumn
&
column
,
const
IDataType
&
type
,
size_t
row_num
)
override
;
String
getName
()
const
override
{
return
"MarkdownRowOutputFormat"
;
}
protected:
const
FormatSettings
format_settings
;
};
}
tests/queries/0_stateless/01231_markdown_format.reference
0 → 100644
浏览文件 @
831c48c5
|id|name|array|
|:-:|:-:|:-:|
|1|name1|[1,2,3]|
|2|name2|[4,5,6]|
|3|name3|[7,8,9]|
tests/queries/0_stateless/01231_markdown_format.sql
0 → 100644
浏览文件 @
831c48c5
DROP
TABLE
IF
EXISTS
makrdown
;
CREATE
TABLE
markdown
(
id
UInt32
,
name
String
,
array
Array
(
Int8
))
ENGINE
=
Memory
;
INSERT
INTO
markdown
VALUES
(
1
,
'name1'
,
[
1
,
2
,
3
]),
(
2
,
'name2'
,
[
4
,
5
,
6
]),
(
3
,
'name3'
,
[
7
,
8
,
9
]);
SELECT
*
FROM
markdown
FORMAT
Markdown
;
DROP
TABLE
IF
EXISTS
markdown
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录