Added IFunction::isDeterministicInScopeOfQuery().

This commit is contained in:
Nikolai Kochetov 2018-08-08 21:21:37 +03:00
parent 4dc87a6fd4
commit 36da1f2871
2 changed files with 7 additions and 2 deletions

View File

@ -473,7 +473,7 @@ DataTypePtr FunctionBuilderImpl::getReturnType(const ColumnsWithTypeAndName & ar
can_run_function_on_dictionary = false; can_run_function_on_dictionary = false;
} }
if (has_type_with_dictionary && can_run_function_on_dictionary) if (canBeExecutedOnLowCardinalityDictionary() && has_type_with_dictionary && can_run_function_on_dictionary)
return std::make_shared<DataTypeWithDictionary>(getReturnTypeWithoutDictionary(args_without_dictionary)); return std::make_shared<DataTypeWithDictionary>(getReturnTypeWithoutDictionary(args_without_dictionary));
else else
return getReturnTypeWithoutDictionary(args_without_dictionary); return getReturnTypeWithoutDictionary(args_without_dictionary);

View File

@ -285,6 +285,9 @@ protected:
*/ */
virtual bool useDefaultImplementationForColumnsWithDictionary() const { return true; } virtual bool useDefaultImplementationForColumnsWithDictionary() const { return true; }
/// If it isn't, will convert all ColumnWithDictionary arguments to full columns.
virtual bool canBeExecutedOnLowCardinalityDictionary() const { return true; }
virtual FunctionBasePtr buildImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & return_type) const = 0; virtual FunctionBasePtr buildImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & return_type) const = 0;
virtual void getLambdaArgumentTypesImpl(DataTypes & /*arguments*/) const virtual void getLambdaArgumentTypesImpl(DataTypes & /*arguments*/) const
@ -309,9 +312,10 @@ public:
/// Override this functions to change default implementation behavior. See details in IMyFunction. /// Override this functions to change default implementation behavior. See details in IMyFunction.
bool useDefaultImplementationForNulls() const override { return true; } bool useDefaultImplementationForNulls() const override { return true; }
bool useDefaultImplementationForConstants() const override { return false; } bool useDefaultImplementationForConstants() const override { return false; }
bool useDefaultImplementationForColumnsWithDictionary() const override { return isDeterministicInScopeOfQuery(); } bool useDefaultImplementationForColumnsWithDictionary() const override { return true; }
ColumnNumbers getArgumentsThatAreAlwaysConstant() const override { return {}; } ColumnNumbers getArgumentsThatAreAlwaysConstant() const override { return {}; }
bool canBeExecutedOnDefaultArguments() const override { return true; } bool canBeExecutedOnDefaultArguments() const override { return true; }
bool canBeExecutedOnLowCardinalityDictionary() const override { return isDeterministicInScopeOfQuery(); }
using PreparedFunctionImpl::execute; using PreparedFunctionImpl::execute;
using FunctionBuilderImpl::getReturnTypeImpl; using FunctionBuilderImpl::getReturnTypeImpl;
@ -459,6 +463,7 @@ protected:
bool useDefaultImplementationForNulls() const override { return function->useDefaultImplementationForNulls(); } bool useDefaultImplementationForNulls() const override { return function->useDefaultImplementationForNulls(); }
bool useDefaultImplementationForColumnsWithDictionary() const override { return function->useDefaultImplementationForColumnsWithDictionary(); } bool useDefaultImplementationForColumnsWithDictionary() const override { return function->useDefaultImplementationForColumnsWithDictionary(); }
bool canBeExecutedOnLowCardinalityDictionary() const override { return function->canBeExecutedOnLowCardinalityDictionary(); }
FunctionBasePtr buildImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & return_type) const override FunctionBasePtr buildImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & return_type) const override
{ {