Skip to content

Commit 3c83bab

Browse files
authored
check for accepted values for accuracy in dcount,dcountif (#375)
* check for accepted values for accuracy in dcount,dcountif * Added functional Testacse and fixed the error msg
1 parent 2a11a8c commit 3c83bab

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/Parsers/Kusto/KustoFunctions/KQLAggregationFunctions.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace DB::ErrorCodes
1010
{
1111
extern const int NOT_IMPLEMENTED;
12+
extern const int BAD_ARGUMENTS;
1213
}
1314

1415
namespace
@@ -26,12 +27,19 @@ uint mapPrecisionAccuracy(const std::optional<std::string> & accuracy)
2627

2728
if (*accuracy == "0")
2829
return 12;
30+
else if (*accuracy == "1")
31+
return 14;
2932
else if (*accuracy == "2")
3033
return 16;
3134
else if (*accuracy == "3")
3235
return 17;
36+
else if (*accuracy == "4")
37+
return 18;
3338
else
34-
return 14;
39+
throw DB::Exception(
40+
DB::ErrorCodes::BAD_ARGUMENTS,
41+
"Accuracy argument must be a constant integer with value 0, 1, 2, 3 or 4 (0 = fast , 1 = default, 2 = accurate, 3 = extra accurate, 4 "
42+
"= super accurate)");
3543
}
3644
}
3745

tests/queries/0_stateless/02366_kql_summarize.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ Customers | summarize MyAvg = avgif(Age, Age<40) by Occupation;
5959
Customers | summarize MySum = sumif(Age, Age<40) by Occupation;
6060
Customers | summarize dcount(Education);
6161
Customers | summarize dcount(Education, 2);
62+
Customers | summarize dcount(Education, 10); -- { clientError 36 }
6263
Customers | summarize dcountif(Education, Occupation=='Professional');
6364
Customers | summarize dcountif(Education, Occupation=='Professional', 2);
65+
Customers | summarize dcountif(Education, Occupation=='Professional', -1); -- { clientError 36 }
6466
Customers | summarize count_ = count() by bin(Age, 10) | order by count_ asc;
6567
Customers | summarize job_count = count() by Occupation | where job_count > 0;
6668
Customers | summarize 'Edu Count'=count() by Education | sort by 'Edu Count' desc; -- { clientError 62 }

0 commit comments

Comments
 (0)