This commit is contained in:
feng lv 2020-11-04 12:15:31 +00:00
parent 7ec73e1f20
commit 269e96f17e
3 changed files with 21 additions and 3 deletions

View File

@ -120,9 +120,11 @@ struct CustomizeAggregateFunctionsSuffixData
void visit(ASTFunction & func, ASTPtr &)
{
if (AggregateFunctionFactory::instance().isAggregateFunctionName(func.name)
&& !endsWith(func.name, customized_func_suffix))
const auto & instance = AggregateFunctionFactory::instance();
if (instance.isAggregateFunctionName(func.name) && !endsWith(func.name, customized_func_suffix))
{
auto properties = instance.tryGetProperties(func.name);
if (properties && !properties->returns_default_when_only_null)
func.name = func.name + customized_func_suffix;
}
}

View File

@ -1,8 +1,16 @@
0
\N
0
\N
\N
\N
0
\N
45
45
10
10
45
45
10
10

View File

@ -7,11 +7,15 @@ CREATE TABLE defaults
SELECT sum(n) FROM defaults;
SELECT sumOrNull(n) FROM defaults;
SELECT count(n) FROM defaults;
SELECT countOrNull(n) FROM defaults;
SET aggregate_functions_null_for_empty=1;
SELECT sum(n) FROM defaults;
SELECT sumOrNull(n) FROM defaults;
SELECT count(n) FROM defaults;
SELECT countOrNull(n) FROM defaults;
INSERT INTO defaults SELECT * FROM numbers(10);
@ -19,10 +23,14 @@ SET aggregate_functions_null_for_empty=0;
SELECT sum(n) FROM defaults;
SELECT sumOrNull(n) FROM defaults;
SELECT count(n) FROM defaults;
SELECT countOrNull(n) FROM defaults;
SET aggregate_functions_null_for_empty=1;
SELECT sum(n) FROM defaults;
SELECT sumOrNull(n) FROM defaults;
SELECT count(n) FROM defaults;
SELECT countOrNull(n) FROM defaults;
DROP TABLE defaults;