make_list_with_nulls_bug1009 fix

This commit is contained in:
root 2022-09-19 11:13:16 -07:00 committed by Yong Wang
parent 49ce24a451
commit 6fa32e3108
3 changed files with 13 additions and 2 deletions

View File

@ -654,7 +654,7 @@ https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/make-seriesoper
`Customers | summarize t = make_list_if(FirstName, Age > 10) by FirstName`
`Customers | summarize t = make_list_if(FirstName, Age > 10, 10) by FirstName`
- [make_list_with_nulls()](https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/make-list-with-nulls-aggfunction)
`Customers | summarize t = make_list_with_nulls(FirstName) by FirstName`
`Customers | summarize t = make_list_with_nulls(Age) by FirstName`
- [make_set()](https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/makeset-aggfunction)
`Customers | summarize t = make_set(FirstName) by FirstName`
`Customers | summarize t = make_set(FirstName, 10) by FirstName`

View File

@ -152,7 +152,14 @@ bool MakeListIf::convertImpl(String & out,IParser::Pos & pos)
bool MakeListWithNulls::convertImpl(String & out,IParser::Pos & pos)
{
return directMapping(out,pos,"groupArray");
String fn_name = getKQLFunctionName(pos);
if (fn_name.empty())
return false;
++pos;
const auto column_name = getConvertedArgument(fn_name,pos);
out = "arrayConcat(groupArray(" + column_name + ") AS ga, arrayMap(x -> null, range(0, toUInt32(count(*)-length(ga)),1)))";
return true;
}
bool MakeSet::convertImpl(String & out,IParser::Pos & pos)

View File

@ -53,5 +53,9 @@ INSTANTIATE_TEST_SUITE_P(ParserKQLQuery, ParserTest,
{
"DataTable | summarize t = percentilew(Bucket, Frequency, 50)",
"SELECT quantileExactWeighted(50 / 100)(Bucket, Frequency) AS t\nFROM DataTable"
},
{
"Customers | summarize t = make_list_with_nulls(Age) by FirstName",
"SELECT\n FirstName,\n arrayConcat(groupArray(Age) AS ga, arrayMap(x -> NULL, range(0, toUInt32(count(*) - length(ga)), 1))) AS t\nFROM Customers\nGROUP BY FirstName"
}
})));