diff --git a/src/Formats/FormatFactory.cpp b/src/Formats/FormatFactory.cpp index 15743365d7d..5013cfb59f4 100644 --- a/src/Formats/FormatFactory.cpp +++ b/src/Formats/FormatFactory.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -448,6 +449,7 @@ OutputFormatPtr FormatFactory::getOutputFormatParallelIfPossible( throw Exception(ErrorCodes::FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT, "Format {} is not suitable for output", name); auto format_settings = _format_settings ? *_format_settings : getFormatSettings(context); + format_settings.is_writing_to_terminal = isWritingToTerminal(buf); const Settings & settings = context->getSettingsRef(); @@ -489,6 +491,7 @@ OutputFormatPtr FormatFactory::getOutputFormat( auto format_settings = _format_settings ? *_format_settings : getFormatSettings(context); format_settings.max_threads = context->getSettingsRef().max_threads; + format_settings.is_writing_to_terminal = format_settings.is_writing_to_terminal = isWritingToTerminal(buf); /** TODO: Materialization is needed, because formats can use the functions `IDataType`, * which only work with full columns. diff --git a/src/Formats/FormatSettings.h b/src/Formats/FormatSettings.h index 10da965f126..a960be9edba 100644 --- a/src/Formats/FormatSettings.h +++ b/src/Formats/FormatSettings.h @@ -34,6 +34,7 @@ struct FormatSettings bool null_as_default = true; bool decimal_trailing_zeros = false; bool defaults_for_omitted_fields = true; + bool is_writing_to_terminal = false; bool seekable_read = true; UInt64 max_rows_to_read_for_schema_inference = 25000; diff --git a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h index 73441ec08ee..253a6a958cc 100644 --- a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h +++ b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.h @@ -4,7 +4,6 @@ #include #include #include -#include namespace DB { @@ -73,7 +72,7 @@ void registerPrettyFormatWithNoEscapesAndMonoBlock(FormatFactory & factory, cons const Block & sample, const FormatSettings & format_settings) { - bool color = !no_escapes && format_settings.pretty.color.valueOr(isWritingToTerminal(buf)); + bool color = !no_escapes && format_settings.pretty.color.valueOr(format_settings.is_writing_to_terminal); return std::make_shared(buf, sample, format_settings, mono_block, color); }); if (!mono_block)