diff --git a/src/Formats/FormatFactory.cpp b/src/Formats/FormatFactory.cpp index c01ecde8542..015b7ee53fc 100644 --- a/src/Formats/FormatFactory.cpp +++ b/src/Formats/FormatFactory.cpp @@ -92,6 +92,11 @@ static FormatSettings getOutputFormatSetting(const Settings & settings, const Co { FormatSettings format_settings; format_settings.enable_streaming = settings.output_format_enable_streaming; + /// Check query context to see if streaming mode was auto set based on the query type + if (context.hasQueryContext()) + { + format_settings.enable_streaming |= context.getQueryContext().getSettings().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; diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index aa05e582150..6e5ab94f0f1 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -180,6 +180,20 @@ static void onExceptionBeforeStart(const String & query_for_logging, Context & c query_log->add(elem); } +static void setQuerySpecificSettings(ASTPtr & ast, Context & context) +{ + if (auto * ast_insert_into = dynamic_cast(ast.get())) + { + if (ast_insert_into->watch) + { + if (context.hasQueryContext()) + { + Context & query_context = const_cast(context).getQueryContext(); + query_context.setSetting("output_format_enable_streaming", 1); + } + } + } +} static std::tuple executeQueryImpl( const char * begin, @@ -246,6 +260,8 @@ static std::tuple executeQueryImpl( throw; } + setQuerySpecificSettings(ast, context); + /// Copy query into string. It will be written to log and presented in processlist. If an INSERT query, string will not include data to insertion. String query(begin, query_end); BlockIO res; @@ -637,6 +653,7 @@ void executeQuery( ASTPtr ast; BlockIO streams; + std::tie(ast, streams) = executeQueryImpl(begin, end, context, false, QueryProcessingStage::Complete, may_have_tail, &istr, true); auto & pipeline = streams.pipeline; diff --git a/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py b/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py index 07b73ade655..ed4e3218438 100755 --- a/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py +++ b/tests/queries/0_stateless/01247_insert_into_watch_live_view_url.py @@ -27,9 +27,6 @@ try: 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')