Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22.8 Backport of #44469 Don't execute and/or/if/multiIf on LowCardinality dictionary #283

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Functions/FunctionsLogical.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class FunctionAnyArityLogical : public IFunction
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(); }

Expand Down
1 change: 1 addition & 0 deletions src/Functions/if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ class FunctionIf : public FunctionIfBase
}
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
Expand Down
1 change: 1 addition & 0 deletions src/Functions/multiIf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class FunctionMultiIf final : public FunctionIfBase
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
size_t getNumberOfArguments() const override { return 0; }
bool useDefaultImplementationForNulls() const override { return false; }
bool canBeExecutedOnLowCardinalityDictionary() const override { return false; }

ColumnNumbers getArgumentsThatDontImplyNullableReturnType(size_t number_of_arguments) const override
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -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;

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UInt8
UInt8
UInt8
UInt8
Original file line number Diff line number Diff line change
@@ -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);