mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #62840 from CurtizJ/fix-format-row
Fix crash in function `formatRow` with `JSON` format and HTTP interface
This commit is contained in:
commit
27aa03983a
@ -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 <bool no_newline>
|
||||
|
@ -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
|
7
tests/queries/0_stateless/03129_format_row_json_http.sh
Executable file
7
tests/queries/0_stateless/03129_format_row_json_http.sh
Executable file
@ -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))"
|
Loading…
Reference in New Issue
Block a user