Add multiIf

This commit is contained in:
Alexey Milovidov 2020-06-29 00:14:38 +03:00
parent 6fa1204698
commit 0bf7a8c554
3 changed files with 24 additions and 1 deletions

View File

@ -39,6 +39,7 @@ public:
bool isVariadic() const override { return true; }
size_t getNumberOfArguments() const override { return 0; }
bool useDefaultImplementationForNulls() const override { return false; }
ColumnNumbers getArgumentsThatDontImplyNullableReturnType(size_t number_of_arguments) const override
{
ColumnNumbers args;
@ -70,7 +71,6 @@ public:
throw Exception{"Invalid number of arguments for function " + getName(),
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH};
for_conditions([&](const DataTypePtr & arg)
{
const IDataType * nested_type;

View File

@ -18,3 +18,23 @@
7\0 FixedString(2)
-8 FixedString(2)
9\0 FixedString(2)
0 String
1 String
-2 String
3 String
-4 String
5 String
-6 String
7 String
-8 String
9 String
0\0 FixedString(2)
1\0 FixedString(2)
-2 FixedString(2)
3\0 FixedString(2)
-4 FixedString(2)
5\0 FixedString(2)
-6 FixedString(2)
7\0 FixedString(2)
-8 FixedString(2)
9\0 FixedString(2)

View File

@ -1,2 +1,5 @@
SELECT if(number % 2, toFixedString(toString(number), 2), toFixedString(toString(-number), 5)) AS x, toTypeName(x) FROM system.numbers LIMIT 10;
SELECT if(number % 2, toFixedString(toString(number), 2), toFixedString(toString(-number), 2)) AS x, toTypeName(x) FROM system.numbers LIMIT 10;
SELECT multiIf(number % 2, toFixedString(toString(number), 2), toFixedString(toString(-number), 5)) AS x, toTypeName(x) FROM system.numbers LIMIT 10;
SELECT multiIf(number % 2, toFixedString(toString(number), 2), toFixedString(toString(-number), 2)) AS x, toTypeName(x) FROM system.numbers LIMIT 10;