1#include <Processors/Formats/Impl/ValuesRowOutputFormat.h>
2#include <Formats/FormatFactory.h>
3
4#include <IO/WriteHelpers.h>
5#include <Columns/IColumn.h>
6#include <DataTypes/IDataType.h>
7
8
9namespace DB
10{
11
12
13ValuesRowOutputFormat::ValuesRowOutputFormat(WriteBuffer & out_, const Block & header_, FormatFactory::WriteCallback callback, const FormatSettings & format_settings_)
14 : IRowOutputFormat(header_, out_, callback), format_settings(format_settings_)
15{
16}
17
18void ValuesRowOutputFormat::writeField(const IColumn & column, const IDataType & type, size_t row_num)
19{
20 type.serializeAsTextQuoted(column, row_num, out, format_settings);
21}
22
23void ValuesRowOutputFormat::writeFieldDelimiter()
24{
25 writeChar(',', out);
26}
27
28void ValuesRowOutputFormat::writeRowStartDelimiter()
29{
30 writeChar('(', out);
31}
32
33void ValuesRowOutputFormat::writeRowEndDelimiter()
34{
35 writeChar(')', out);
36}
37
38void ValuesRowOutputFormat::writeRowBetweenDelimiter()
39{
40 writeCString(",", out);
41}
42
43
44void registerOutputFormatProcessorValues(FormatFactory & factory)
45{
46 factory.registerOutputFormatProcessor("Values", [](
47 WriteBuffer & buf,
48 const Block & sample,
49 FormatFactory::WriteCallback callback,
50 const FormatSettings & settings)
51 {
52 return std::make_shared<ValuesRowOutputFormat>(buf, sample, callback, settings);
53 });
54}
55
56}
57