| 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 | |
| 9 | namespace DB |
| 10 | { |
| 11 | |
| 12 | |
| 13 | ValuesRowOutputFormat::ValuesRowOutputFormat(WriteBuffer & out_, const Block & , FormatFactory::WriteCallback callback, const FormatSettings & format_settings_) |
| 14 | : IRowOutputFormat(header_, out_, callback), format_settings(format_settings_) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | void ValuesRowOutputFormat::writeField(const IColumn & column, const IDataType & type, size_t row_num) |
| 19 | { |
| 20 | type.serializeAsTextQuoted(column, row_num, out, format_settings); |
| 21 | } |
| 22 | |
| 23 | void ValuesRowOutputFormat::writeFieldDelimiter() |
| 24 | { |
| 25 | writeChar(',', out); |
| 26 | } |
| 27 | |
| 28 | void ValuesRowOutputFormat::writeRowStartDelimiter() |
| 29 | { |
| 30 | writeChar('(', out); |
| 31 | } |
| 32 | |
| 33 | void ValuesRowOutputFormat::writeRowEndDelimiter() |
| 34 | { |
| 35 | writeChar(')', out); |
| 36 | } |
| 37 | |
| 38 | void ValuesRowOutputFormat::writeRowBetweenDelimiter() |
| 39 | { |
| 40 | writeCString("," , out); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | void 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 | |