Skip to content

Commit

Permalink
Merge pull request #391 from ClibMouse/Kusto-p3_fix_makeseries_zip
Browse files Browse the repository at this point in the history
Kusto-phase3: fix make-series bug
  • Loading branch information
kashwy authored Sep 6, 2023
2 parents bc8d583 + 8529feb commit 36d6fe2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
15 changes: 11 additions & 4 deletions src/Parsers/Kusto/ParserKQLMakeSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ bool ParserKQLMakeSeries ::parseAggregationColumns(AggregationColumns & aggregat
if (pos->type == TokenType::Comma && bracket_count.isZero())
{
parseSingleAggregationColumn(aggregation_columns, begin, pos, column_index);
begin = pos;
++begin;
}
if (String(pos->begin, pos->end) == "on" && bracket_count.isZero())
Expand Down Expand Up @@ -361,6 +362,10 @@ bool ParserKQLMakeSeries ::makeSeries(KQLMakeSeries & kql_make_series, ASTPtr &
if (from_to_step.is_timespan)
{
axis_column_format = std::format("toFloat64(toDateTime64({}, 9, 'UTC'))", axis_column);
if (!start_str.empty())
{
start_str = std::format("date_trunc('second', {})", start_str);
}
}
else
axis_column_format = std::format("toFloat64({})", axis_column);
Expand Down Expand Up @@ -442,20 +447,22 @@ bool ParserKQLMakeSeries ::makeSeries(KQLMakeSeries & kql_make_series, ASTPtr &
auto axis_and_agg_alias_list = axis_column;
auto final_axis_agg_alias_list = std::format("tupleElement(zipped,1) AS {}", axis_column);
int idx = 2;
int agg_count = 1;
for (auto agg_column : aggregation_columns)
{
String agg_group_column = std::format(
"arrayConcat(groupArray({}_ali) as ga, arrayMap(x -> ({}),range(0,toUInt32({} - length(ga) < 0 ? 0 : {} - length(ga)),1))) as "
"{}",
"arrayConcat(groupArray({0}_ali) as ga{3}, arrayMap(x -> ({1}),range(0,toUInt32({2} - length(ga{3}) < 0 ? 0 : {2} - length(ga{3})),1))) as "
"{0}",
agg_column.alias,
agg_column.default_value,
range_len,
range_len,
agg_column.alias);
agg_count
);
main_query = main_query.empty() ? agg_group_column : main_query + ", " + agg_group_column;

axis_and_agg_alias_list += ", " + agg_column.alias;
final_axis_agg_alias_list += std::format(", tupleElement(zipped,{}) AS {}", idx, agg_column.alias);
++agg_count;
}

if (from_to_step.is_timespan)
Expand Down
Loading

0 comments on commit 36d6fe2

Please sign in to comment.