mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
change as request
This commit is contained in:
parent
68aebce89f
commit
a749223251
@ -6,11 +6,10 @@
|
||||
#include <Functions/FunctionHelpers.h>
|
||||
#include <Functions/IFunction.h>
|
||||
#include <Functions/formatString.h>
|
||||
#include <IO/Operators.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/printf.h>
|
||||
@ -22,6 +21,7 @@ namespace ErrorCodes
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -52,10 +52,9 @@ private:
|
||||
|
||||
[[maybe_unused]] String toString() const
|
||||
{
|
||||
std::ostringstream oss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
|
||||
oss << "format:" << format << ", rows:" << rows << ", is_literal:" << is_literal << ", input:" << input.dumpStructure()
|
||||
<< std::endl;
|
||||
return oss.str();
|
||||
WriteBufferFromOwnString buf;
|
||||
buf << "format:" << format << ", rows:" << rows << ", is_literal:" << is_literal << ", input:" << input.dumpStructure() << "\n";
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
private:
|
||||
@ -229,9 +228,31 @@ public:
|
||||
ColumnsWithTypeAndName concat_args(instructions.size());
|
||||
for (size_t i = 0; i < instructions.size(); ++i)
|
||||
{
|
||||
// std::cout << "instruction[" << i << "]:" << instructions[i].toString() << std::endl;
|
||||
concat_args[i] = instructions[i].execute();
|
||||
// std::cout << "concat_args[" << i << "]:" << concat_args[i].dumpStructure() << std::endl;
|
||||
const auto & instruction = instructions[i];
|
||||
try
|
||||
{
|
||||
// std::cout << "instruction[" << i << "]:" << instructions[i].toString() << std::endl;
|
||||
concat_args[i] = instruction.execute();
|
||||
// std::cout << "concat_args[" << i << "]:" << concat_args[i].dumpStructure() << std::endl;
|
||||
}
|
||||
catch (const fmt::v9::format_error & e)
|
||||
{
|
||||
if (instruction.is_literal)
|
||||
throw Exception(
|
||||
ErrorCodes::BAD_ARGUMENTS,
|
||||
"Bad format {} in function {} without input argument, reason: {}",
|
||||
instruction.format,
|
||||
getName(),
|
||||
e.what());
|
||||
else
|
||||
throw Exception(
|
||||
ErrorCodes::BAD_ARGUMENTS,
|
||||
"Bad format {} in function {} with {} as input argument, reason: {}",
|
||||
instructions[i].format,
|
||||
getName(),
|
||||
instruction.input.dumpStructure(),
|
||||
e.what());
|
||||
}
|
||||
}
|
||||
|
||||
auto res = function_concat->build(concat_args)->execute(concat_args, std::make_shared<DataTypeString>(), input_rows_count);
|
||||
|
@ -31,4 +31,9 @@ select printf('%%.2e: %.2e', 123.456) = '%.2e: 1.23e+02';
|
||||
select printf('%%.2g: %.2g', 123.456) = '%.2g: 1.2e+02';
|
||||
|
||||
-- Testing character formats with precision
|
||||
select printf('%%.2s: %.2s', 'abc') = '%.2s: ab';
|
||||
select printf('%%.2s: %.2s', 'abc') = '%.2s: ab';
|
||||
|
||||
select printf('%%X: %X', 123.123); -- { serverError BAD_ARGUMENTS }
|
||||
select printf('%%A: %A', 'abc'); -- { serverError BAD_ARGUMENTS }
|
||||
select printf('%%s: %s', 100); -- { serverError BAD_ARGUMENTS }
|
||||
select printf('%%n: %n', 100); -- { serverError BAD_ARGUMENTS }
|
||||
|
Loading…
Reference in New Issue
Block a user