2019-02-19 18:41:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <Formats/FormatSettings.h>
|
|
|
|
#include <Processors/Formats/IRowOutputFormat.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class WriteBuffer;
|
|
|
|
|
|
|
|
/** A stream for outputting data in tsv format.
|
|
|
|
*/
|
|
|
|
class TabSeparatedRowOutputFormat : public IRowOutputFormat
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** with_names - output in the first line a header with column names
|
|
|
|
* with_types - output the next line header with the names of the types
|
|
|
|
*/
|
2019-08-20 11:17:57 +00:00
|
|
|
TabSeparatedRowOutputFormat(
|
|
|
|
WriteBuffer & out_,
|
|
|
|
const Block & header_,
|
|
|
|
bool with_names_,
|
|
|
|
bool with_types_,
|
2020-10-07 18:51:10 +00:00
|
|
|
const RowOutputFormatParams & params_,
|
2019-08-20 11:17:57 +00:00
|
|
|
const FormatSettings & format_settings_);
|
2019-02-19 18:41:18 +00:00
|
|
|
|
|
|
|
String getName() const override { return "TabSeparatedRowOutputFormat"; }
|
|
|
|
|
2021-03-09 14:46:52 +00:00
|
|
|
void writeField(const IColumn & column, const ISerialization & serialization, size_t row_num) override;
|
2019-02-19 18:41:18 +00:00
|
|
|
void writeFieldDelimiter() override;
|
|
|
|
void writeRowEndDelimiter() override;
|
|
|
|
void writeBeforeTotals() override;
|
|
|
|
void writeBeforeExtremes() override;
|
|
|
|
|
2020-08-04 20:49:30 +00:00
|
|
|
void doWritePrefix() override;
|
|
|
|
|
2019-02-19 18:41:18 +00:00
|
|
|
/// https://www.iana.org/assignments/media-types/text/tab-separated-values
|
|
|
|
String getContentType() const override { return "text/tab-separated-values; charset=UTF-8"; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
bool with_names;
|
|
|
|
bool with_types;
|
|
|
|
const FormatSettings format_settings;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|