Merge pull request #44469 from Avogar/low-card-if

Don't execute and/or/if/multiIf on LowCardinality dictionary
This commit is contained in:
Kruglov Pavel 2022-12-27 16:59:42 +01:00 committed by GitHub
commit f95eabc192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 0 deletions

View File

@ -176,6 +176,7 @@ public:
ColumnPtr executeShortCircuit(ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type) const;
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
size_t getNumberOfArguments() const override { return 0; }
bool canBeExecutedOnLowCardinalityDictionary() const override { return false; }
bool useDefaultImplementationForNulls() const override { return !Impl::specialImplementationForNulls(); }

View File

@ -1026,6 +1026,7 @@ public:
}
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
ColumnNumbers getArgumentsThatDontImplyNullableReturnType(size_t /*number_of_arguments*/) const override { return {0}; }
bool canBeExecutedOnLowCardinalityDictionary() const override { return false; }
/// Get result types by argument types. If the function does not apply to these arguments, throw an exception.
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override

View File

@ -51,6 +51,7 @@ public:
size_t getNumberOfArguments() const override { return 0; }
bool useDefaultImplementationForNulls() const override { return false; }
bool useDefaultImplementationForNothing() const override { return false; }
bool canBeExecutedOnLowCardinalityDictionary() const override { return false; }
ColumnNumbers getArgumentsThatDontImplyNullableReturnType(size_t number_of_arguments) const override
{

View File

@ -0,0 +1,5 @@
create table if not exists t (`arr.key` Array(LowCardinality(String)), `arr.value` Array(LowCardinality(String))) engine = Memory;
insert into t (`arr.key`, `arr.value`) values (['a'], ['b']);
select if(true, if(lowerUTF8(arr.key) = 'a', 1, 2), 3) as x from t left array join arr;
drop table t;

View File

@ -0,0 +1,4 @@
UInt8
UInt8
UInt8
UInt8

View File

@ -0,0 +1,5 @@
select toTypeName(if(toLowCardinality(number % 2), 1, 2)) from numbers(1);
select toTypeName(multiIf(toLowCardinality(number % 2), 1, 1, 2, 3)) from numbers(1);
select toTypeName(toLowCardinality(number % 2) and 2) from numbers(1);
select toTypeName(toLowCardinality(number % 2) or 2) from numbers(1);