diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-09 10:11:16 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-09 10:33:35 +0300 |
commit | fa9347ea5cf4447897b525032be9a711cc3dc583 (patch) | |
tree | 4f3d4f493e4cfb43a3c8b5f7e279621c41e0e978 /contrib/clickhouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp | |
parent | f82bfd2a08a51c4815a4cde64974f819ed4f7128 (diff) | |
download | ydb-fa9347ea5cf4447897b525032be9a711cc3dc583.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/clickhouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp')
-rw-r--r-- | contrib/clickhouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/contrib/clickhouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp b/contrib/clickhouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp index 5b8f6cc1af..b805547201 100644 --- a/contrib/clickhouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp +++ b/contrib/clickhouse/src/Processors/Formats/Impl/JSONEachRowRowOutputFormat.cpp @@ -14,10 +14,12 @@ JSONEachRowRowOutputFormat::JSONEachRowRowOutputFormat( const Block & header_, const FormatSettings & settings_, bool pretty_json_) - : RowOutputFormatWithUTF8ValidationAdaptor(settings_.json.validate_utf8, header_, out_), - pretty_json(pretty_json_), - settings(settings_) + : RowOutputFormatWithExceptionHandlerAdaptor<RowOutputFormatWithUTF8ValidationAdaptor, bool>( + header_, out_, settings_.json.valid_output_on_exception, settings_.json.validate_utf8) + , pretty_json(pretty_json_) + , settings(settings_) { + ostr = RowOutputFormatWithExceptionHandlerAdaptor::getWriteBufferPtr(); fields = JSONUtils::makeNamesValidJSONStrings(getPort(PortKind::Main).getHeader().getNames(), settings, settings.json.validate_utf8); } @@ -76,10 +78,24 @@ void JSONEachRowRowOutputFormat::writePrefix() void JSONEachRowRowOutputFormat::writeSuffix() { + if (!exception_message.empty()) + { + if (haveWrittenData()) + writeRowBetweenDelimiter(); + writeRowStartDelimiter(); + JSONUtils::writeException(exception_message, *ostr, settings, pretty_json ? 1 : 0); + writeRowEndDelimiter(); + } + if (settings.json.array_of_rows) writeCString("\n]\n", *ostr); } +void JSONEachRowRowOutputFormat::resetFormatterImpl() +{ + RowOutputFormatWithExceptionHandlerAdaptor::resetFormatterImpl(); + ostr = RowOutputFormatWithExceptionHandlerAdaptor::getWriteBufferPtr(); +} void registerOutputFormatJSONEachRow(FormatFactory & factory) { |