Adding support for output_format_enable_streaming format setting.

This commit is contained in:
Vitaliy Zakaznikov 2020-04-26 15:44:11 +02:00
parent cf8bc71b21
commit 369b4d53ef
6 changed files with 14 additions and 0 deletions

View File

@ -176,6 +176,7 @@ struct Settings : public SettingsCollection<Settings>
\
M(SettingString, count_distinct_implementation, "uniqExact", "What aggregate function to use for implementation of count(DISTINCT ...)", 0) \
\
M(SettingBool, output_format_enable_streaming, false, "Enable streaming in output formats that support it.", 0) \
M(SettingBool, output_format_write_statistics, true, "Write statistics about read rows, bytes, time elapsed in suitable output formats.", 0) \
\
M(SettingBool, add_http_cors_header, false, "Write add http CORS header.", 0) \

View File

@ -87,6 +87,7 @@ static FormatSettings getInputFormatSetting(const Settings & settings, const Con
static FormatSettings getOutputFormatSetting(const Settings & settings, const Context & context)
{
FormatSettings format_settings;
format_settings.enable_streaming = settings.output_format_enable_streaming;
format_settings.json.quote_64bit_integers = settings.output_format_json_quote_64bit_integers;
format_settings.json.quote_denormals = settings.output_format_json_quote_denormals;
format_settings.json.escape_forward_slashes = settings.output_format_json_escape_forward_slashes;

View File

@ -13,6 +13,8 @@ namespace DB
*/
struct FormatSettings
{
bool enable_streaming = false;
struct JSON
{
bool quote_64bit_integers = true;

View File

@ -18,6 +18,12 @@ CSVRowOutputFormat::CSVRowOutputFormat(WriteBuffer & out_, const Block & header_
data_types[i] = sample.safeGetByPosition(i).type;
}
void CSVRowOutputFormat::consume(DB::Chunk chunk)
{
IRowOutputFormat::consume(std::move(chunk));
if (format_settings.enable_streaming)
flush();
}
void CSVRowOutputFormat::writePrefix()
{

View File

@ -39,6 +39,7 @@ public:
protected:
void consume(Chunk chunk) override;
bool with_names;
const FormatSettings format_settings;
DataTypes data_types;

View File

@ -24,6 +24,9 @@ with client(name='client1>', log=log) as client1, client(name='client2>', log=lo
client1.send('SET allow_experimental_live_view = 1')
client1.expect(prompt)
client1.send('SET output_format_enable_streaming = 1')
client1.expect(prompt)
client1.send('DROP TABLE IF EXISTS test.lv')
client1.expect(prompt)
client1.send('DROP TABLE IF EXISTS test.mt')