diff --git a/src/Functions/formatRow.cpp b/src/Functions/formatRow.cpp index 1ac6becfb15..5a67ce158a7 100644 --- a/src/Functions/formatRow.cpp +++ b/src/Functions/formatRow.cpp @@ -38,8 +38,14 @@ public: : format_name(std::move(format_name_)) , arguments_column_names(std::move(arguments_column_names_)) , context(std::move(context_)) + , format_settings(getFormatSettings(context)) { FormatFactory::instance().checkFormatName(format_name); + + /// We don't need handling exceptions while formatting as a row. + /// But it can be enabled in query sent via http interface. + format_settings.json.valid_output_on_exception = false; + format_settings.xml.valid_output_on_exception = false; } String getName() const override { return name; } @@ -68,7 +74,6 @@ public: } materializeBlockInplace(arg_columns); - auto format_settings = getFormatSettings(context); auto out = FormatFactory::instance().getOutputFormat(format_name, buffer, arg_columns, context, format_settings); /// This function make sense only for row output formats. @@ -104,6 +109,7 @@ private: String format_name; Names arguments_column_names; ContextPtr context; + FormatSettings format_settings; }; template diff --git a/tests/queries/0_stateless/03129_format_row_json_http.reference b/tests/queries/0_stateless/03129_format_row_json_http.reference new file mode 100644 index 00000000000..02f4f51d500 --- /dev/null +++ b/tests/queries/0_stateless/03129_format_row_json_http.reference @@ -0,0 +1,15 @@ +{"number":"0"}\n +{"number":"1"}\n +{"number":"2"}\n +{"number":"3"}\n +{"number":"4"}\n +{"number":"5"}\n +{"number":"6"}\n +{"number":"7"}\n +{"number":"8"}\n +{"number":"9"}\n +{"number":"10"}\n +{"number":"11"}\n +{"number":"12"}\n +{"number":"13"}\n +{"number":"14"}\n diff --git a/tests/queries/0_stateless/03129_format_row_json_http.sh b/tests/queries/0_stateless/03129_format_row_json_http.sh new file mode 100755 index 00000000000..729a5ef563f --- /dev/null +++ b/tests/queries/0_stateless/03129_format_row_json_http.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL" --data-binary "SELECT formatRow('JSONEachRow', number) as test FROM (SELECT number FROM numbers(15))"