mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #31001 from Avogar/fix-format-row
Fix segfault in formatRow function
This commit is contained in:
commit
0936d90210
@ -8,6 +8,7 @@
|
||||
#include <IO/WriteBufferFromVector.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Processors/Formats/IOutputFormat.h>
|
||||
#include <Processors/Formats/IRowOutputFormat.h>
|
||||
#include <base/map.h>
|
||||
|
||||
|
||||
@ -18,6 +19,7 @@ namespace ErrorCodes
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||
extern const int UNKNOWN_FORMAT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -70,6 +72,11 @@ public:
|
||||
writeChar('\0', buffer);
|
||||
offsets[row] = buffer.count();
|
||||
});
|
||||
|
||||
/// This function make sense only for row output formats.
|
||||
if (!dynamic_cast<IRowOutputFormat *>(out.get()))
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Cannot turn rows into a {} format strings. {} function supports only row output formats", format_name, getName());
|
||||
|
||||
out->write(arg_columns);
|
||||
return col_str;
|
||||
}
|
||||
|
6
tests/queries/0_stateless/02113_format_row_bug.sql
Normal file
6
tests/queries/0_stateless/02113_format_row_bug.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- Tags: no-fasttest
|
||||
|
||||
select formatRow('ORC', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
||||
select formatRow('Parquet', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
||||
select formatRow('Arrow', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
||||
select formatRow('Native', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
Loading…
Reference in New Issue
Block a user