mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 21:51:57 +00:00
Fixed clang-tidy and Arch tests
This commit is contained in:
parent
b688fe5443
commit
9e82ed1d04
@ -128,8 +128,8 @@ String IParserKQLFunction::generateUniqueIdentifier()
|
|||||||
|
|
||||||
String IParserKQLFunction::getArgument(const String & function_name, DB::IParser::Pos & pos, const ArgumentState argument_state)
|
String IParserKQLFunction::getArgument(const String & function_name, DB::IParser::Pos & pos, const ArgumentState argument_state)
|
||||||
{
|
{
|
||||||
if (auto optionalArgument = getOptionalArgument(function_name, pos, argument_state))
|
if (auto optional_argument = getOptionalArgument(function_name, pos, argument_state))
|
||||||
return std::move(*optionalArgument);
|
return std::move(*optional_argument);
|
||||||
|
|
||||||
throw Exception(std::format("Required argument was not provided in {}", function_name), ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
throw Exception(std::format("Required argument was not provided in {}", function_name), ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ String IParserKQLFunction::getConvertedArgument(const String & fn_name, IParser:
|
|||||||
if (pos->type == TokenType::Comma || pos->type == TokenType::ClosingRoundBracket || pos->type == TokenType::ClosingSquareBracket)
|
if (pos->type == TokenType::Comma || pos->type == TokenType::ClosingRoundBracket || pos->type == TokenType::ClosingSquareBracket)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (auto token : tokens)
|
for (auto const & token : tokens)
|
||||||
converted_arg = converted_arg.empty() ? token : converted_arg + " " + token;
|
converted_arg = converted_arg.empty() ? token : converted_arg + " " + token;
|
||||||
|
|
||||||
return converted_arg;
|
return converted_arg;
|
||||||
@ -342,31 +342,31 @@ String IParserKQLFunction::getExpression(IParser::Pos & pos)
|
|||||||
int IParserKQLFunction::getNullCounts(String arg)
|
int IParserKQLFunction::getNullCounts(String arg)
|
||||||
{
|
{
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
int nullCounts = 0;
|
int null_counts = 0;
|
||||||
for (size_t i = 0; i < arg.size(); i++)
|
for (char & i : arg)
|
||||||
{
|
{
|
||||||
if (arg[i] == 'n')
|
if (i == 'n')
|
||||||
arg[i] = 'N';
|
i = 'N';
|
||||||
if (arg[i] == 'u')
|
if (i == 'u')
|
||||||
arg[i] = 'U';
|
i = 'U';
|
||||||
if (arg[i] == 'l')
|
if (i == 'l')
|
||||||
arg[i] = 'L';
|
i = 'L';
|
||||||
}
|
}
|
||||||
while ((index = arg.find("NULL", index)) != std::string::npos)
|
while ((index = arg.find("NULL", index)) != std::string::npos)
|
||||||
{
|
{
|
||||||
index += 4;
|
index += 4;
|
||||||
nullCounts += 1;
|
null_counts += 1;
|
||||||
}
|
}
|
||||||
return nullCounts;
|
return null_counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IParserKQLFunction::IParserKQLFunction::getArrayLength(String arg)
|
int IParserKQLFunction::IParserKQLFunction::getArrayLength(String arg)
|
||||||
{
|
{
|
||||||
int array_length = 0;
|
int array_length = 0;
|
||||||
bool comma_found = false;
|
bool comma_found = false;
|
||||||
for (size_t i = 0; i < arg.size(); i++)
|
for (char i : arg)
|
||||||
{
|
{
|
||||||
if (arg[i] == ',')
|
if (i == ',')
|
||||||
{
|
{
|
||||||
comma_found = true;
|
comma_found = true;
|
||||||
array_length += 1;
|
array_length += 1;
|
||||||
@ -389,7 +389,7 @@ String IParserKQLFunction::ArraySortHelper(String & out, IParser::Pos & pos, boo
|
|||||||
reverse = "Reverse";
|
reverse = "Reverse";
|
||||||
++pos;
|
++pos;
|
||||||
String first_arg = getConvertedArgument(fn_name, pos);
|
String first_arg = getConvertedArgument(fn_name, pos);
|
||||||
int nullCount = getNullCounts(first_arg);
|
int null_count = getNullCounts(first_arg);
|
||||||
if (pos->type == TokenType::Comma)
|
if (pos->type == TokenType::Comma)
|
||||||
++pos;
|
++pos;
|
||||||
out = "array(";
|
out = "array(";
|
||||||
@ -423,14 +423,14 @@ String IParserKQLFunction::ArraySortHelper(String & out, IParser::Pos & pos, boo
|
|||||||
out += "array" + reverse + "Sort(" + first_arg + ")";
|
out += "array" + reverse + "Sort(" + first_arg + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argument_list.size() > 0)
|
if (!argument_list.empty())
|
||||||
{
|
{
|
||||||
String temp_first_arg = first_arg;
|
String temp_first_arg = first_arg;
|
||||||
int first_arg_length = getArrayLength(temp_first_arg);
|
int first_arg_length = getArrayLength(temp_first_arg);
|
||||||
|
|
||||||
if (nullCount > 0 && expr.empty())
|
if (null_count > 0 && expr.empty())
|
||||||
expr = "true";
|
expr = "true";
|
||||||
if (nullCount > 0)
|
if (null_count > 0)
|
||||||
first_arg = "if (" + expr + ", array" + reverse + "Sort(" + first_arg + "), concat(arraySlice(array" + reverse + "Sort("
|
first_arg = "if (" + expr + ", array" + reverse + "Sort(" + first_arg + "), concat(arraySlice(array" + reverse + "Sort("
|
||||||
+ first_arg + ") as as1, indexOf(as1, NULL) as len1 ), arraySlice( as1, 1, len1-1) ) )";
|
+ first_arg + ") as as1, indexOf(as1, NULL) as len1 ), arraySlice( as1, 1, len1-1) ) )";
|
||||||
else
|
else
|
||||||
@ -438,19 +438,19 @@ String IParserKQLFunction::ArraySortHelper(String & out, IParser::Pos & pos, boo
|
|||||||
|
|
||||||
out += first_arg;
|
out += first_arg;
|
||||||
|
|
||||||
for (size_t i = 0; i < argument_list.size(); i++)
|
for (auto & i : argument_list)
|
||||||
{
|
{
|
||||||
out += " , ";
|
out += " , ";
|
||||||
if (first_arg_length != getArrayLength(argument_list[i]))
|
if (first_arg_length != getArrayLength(i))
|
||||||
out += "array(NULL)";
|
out += "array(NULL)";
|
||||||
else if (nullCount > 0)
|
else if (null_count > 0)
|
||||||
out += "If (" + expr + "," + "array" + reverse + "Sort((x, y) -> y, " + argument_list[i] + "," + temp_first_arg
|
out += "If (" + expr + "," + "array" + reverse + "Sort((x, y) -> y, " + i + "," + temp_first_arg
|
||||||
+ "), arrayConcat(arraySlice(" + "array" + reverse + "Sort((x, y) -> y, " + argument_list[i] + "," + temp_first_arg
|
+ "), arrayConcat(arraySlice(" + "array" + reverse + "Sort((x, y) -> y, " + i + "," + temp_first_arg
|
||||||
+ ") , length(" + temp_first_arg + ") - " + std::to_string(nullCount) + " + 1) , arraySlice(" + "array" + reverse
|
+ ") , length(" + temp_first_arg + ") - " + std::to_string(null_count) + " + 1) , arraySlice(" + "array" + reverse
|
||||||
+ "Sort((x, y) -> y, " + argument_list[i] + "," + temp_first_arg + ") , 1, length(" + temp_first_arg + ") - "
|
+ "Sort((x, y) -> y, " + i + "," + temp_first_arg + ") , 1, length(" + temp_first_arg + ") - "
|
||||||
+ std::to_string(nullCount) + ") ) )";
|
+ std::to_string(null_count) + ") ) )";
|
||||||
else
|
else
|
||||||
out += "array" + reverse + "Sort((x, y) -> y, " + argument_list[i] + "," + temp_first_arg + ")";
|
out += "array" + reverse + "Sort((x, y) -> y, " + i + "," + temp_first_arg + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out += " )";
|
out += " )";
|
||||||
|
@ -142,7 +142,7 @@ bool ToDecimal::convertImpl(String & out, IParser::Pos & pos)
|
|||||||
out = "NULL";
|
out = "NULL";
|
||||||
else if (std::regex_match(res, expr))
|
else if (std::regex_match(res, expr))
|
||||||
{
|
{
|
||||||
auto exponential_pos = res.find("e");
|
auto exponential_pos = res.find('e');
|
||||||
if (res[exponential_pos + 1] == '+' || res[exponential_pos + 1] == '-')
|
if (res[exponential_pos + 1] == '+' || res[exponential_pos + 1] == '-')
|
||||||
scale = std::stoi(res.substr(exponential_pos + 2, res.length()));
|
scale = std::stoi(res.substr(exponential_pos + 2, res.length()));
|
||||||
else
|
else
|
||||||
@ -152,7 +152,7 @@ bool ToDecimal::convertImpl(String & out, IParser::Pos & pos)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (const auto dot_pos = res.find("."); dot_pos != String::npos)
|
if (const auto dot_pos = res.find('.'); dot_pos != String::npos)
|
||||||
{
|
{
|
||||||
const auto tmp = res.substr(0, dot_pos - 1);
|
const auto tmp = res.substr(0, dot_pos - 1);
|
||||||
const auto tmp_length = static_cast<int>(std::ssize(tmp));
|
const auto tmp_length = static_cast<int>(std::ssize(tmp));
|
||||||
|
@ -232,7 +232,7 @@ bool DatatypeDecimal::convertImpl(String & out, IParser::Pos & pos)
|
|||||||
|
|
||||||
if (std::regex_match(arg, expr))
|
if (std::regex_match(arg, expr))
|
||||||
{
|
{
|
||||||
auto exponential_pos = arg.find("e");
|
auto exponential_pos = arg.find('e');
|
||||||
if (arg[exponential_pos + 1] == '+' || arg[exponential_pos + 1] == '-')
|
if (arg[exponential_pos + 1] == '+' || arg[exponential_pos + 1] == '-')
|
||||||
scale = std::stoi(arg.substr(exponential_pos + 2, arg.length()));
|
scale = std::stoi(arg.substr(exponential_pos + 2, arg.length()));
|
||||||
else
|
else
|
||||||
@ -242,7 +242,7 @@ bool DatatypeDecimal::convertImpl(String & out, IParser::Pos & pos)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto dot_pos = arg.find("."); dot_pos != String::npos)
|
if (const auto dot_pos = arg.find('.'); dot_pos != String::npos)
|
||||||
{
|
{
|
||||||
const auto length = static_cast<int>(std::ssize(arg.substr(0, dot_pos - 1)));
|
const auto length = static_cast<int>(std::ssize(arg.substr(0, dot_pos - 1)));
|
||||||
scale = std::max(precision - length, 0);
|
scale = std::max(precision - length, 0);
|
||||||
|
@ -462,19 +462,19 @@ bool ParseURL::convertImpl(String & out, IParser::Pos & pos)
|
|||||||
++pos;
|
++pos;
|
||||||
const String url = getConvertedArgument(fn_name, pos);
|
const String url = getConvertedArgument(fn_name, pos);
|
||||||
|
|
||||||
const String scheme = std::format("concat('\"Scheme\":\"', protocol({0}),'\"')", url);
|
const String scheme = std::format(R"(concat('"Scheme":"', protocol({0}),'"'))", url);
|
||||||
const String host = std::format("concat('\"Host\":\"', domain({0}),'\"')", url);
|
const String host = std::format(R"(concat('"Host":"', domain({0}),'"'))", url);
|
||||||
const String port = std::format("concat('\"Port\":\"', toString(port({0})),'\"')", url);
|
const String port = std::format(R"(concat('"Port":"', toString(port({0})),'"'))", url);
|
||||||
const String path = std::format("concat('\"Path\":\"', path({0}),'\"')", url);
|
const String path = std::format(R"(concat('"Path":"', path({0}),'"'))", url);
|
||||||
const String username_pwd = std::format("netloc({0})", url);
|
const String username_pwd = std::format("netloc({0})", url);
|
||||||
const String query_string = std::format("queryString({0})", url);
|
const String query_string = std::format("queryString({0})", url);
|
||||||
const String fragment = std::format("concat('\"Fragment\":\"',fragment({0}),'\"')", url);
|
const String fragment = std::format(R"(concat('"Fragment":"',fragment({0}),'"'))", url);
|
||||||
const String username = std::format(
|
const String username = std::format(
|
||||||
"concat('\"Username\":\"', arrayElement(splitByChar(':',arrayElement(splitByChar('@',{0}) ,1)),1),'\"')", username_pwd);
|
R"(concat('"Username":"', arrayElement(splitByChar(':',arrayElement(splitByChar('@',{0}) ,1)),1),'"'))", username_pwd);
|
||||||
const String password = std::format(
|
const String password = std::format(
|
||||||
"concat('\"Password\":\"', arrayElement(splitByChar(':',arrayElement(splitByChar('@',{0}) ,1)),2),'\"')", username_pwd);
|
R"(concat('"Password":"', arrayElement(splitByChar(':',arrayElement(splitByChar('@',{0}) ,1)),2),'"'))", username_pwd);
|
||||||
const String query_parameters = std::format(
|
const String query_parameters = std::format(
|
||||||
"concat('\"Query Parameters\":', concat('{{\"', replace(replace({}, '=', '\":\"'),'&','\",\"') ,'\"}}'))", query_string);
|
R"(concat('"Query Parameters":', concat('{{"', replace(replace({}, '=', '":"'),'&','","') ,'"}}')))", query_string);
|
||||||
|
|
||||||
out = std::format(
|
out = std::format(
|
||||||
"concat('{{',{},',',{},',',{},',',{},',',{},',',{},',',{},',',{},'}}')",
|
"concat('{{',{},',',{},',',{},',',{},',',{},',',{},',',{},',',{},'}}')",
|
||||||
@ -499,7 +499,7 @@ bool ParseURLQuery::convertImpl(String & out, IParser::Pos & pos)
|
|||||||
|
|
||||||
const String query_string = std::format("if (position({},'?') > 0, queryString({}), {})", query, query, query);
|
const String query_string = std::format("if (position({},'?') > 0, queryString({}), {})", query, query, query);
|
||||||
const String query_parameters = std::format(
|
const String query_parameters = std::format(
|
||||||
"concat('\"Query Parameters\":', concat('{{\"', replace(replace({}, '=', '\":\"'),'&','\",\"') ,'\"}}'))", query_string);
|
R"(concat('"Query Parameters":', concat('{{"', replace(replace({}, '=', '":"'),'&','","') ,'"}}')))", query_string);
|
||||||
out = std::format("concat('{{',{},'}}')", query_parameters);
|
out = std::format("concat('{{',{},'}}')", query_parameters);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -666,21 +666,21 @@ bool SubString::convertImpl(String & out, IParser::Pos & pos)
|
|||||||
String source = getConvertedArgument(fn_name, pos);
|
String source = getConvertedArgument(fn_name, pos);
|
||||||
|
|
||||||
++pos;
|
++pos;
|
||||||
String startingIndex = getConvertedArgument(fn_name, pos);
|
String starting_index = getConvertedArgument(fn_name, pos);
|
||||||
|
|
||||||
if (pos->type == TokenType::Comma)
|
if (pos->type == TokenType::Comma)
|
||||||
{
|
{
|
||||||
++pos;
|
++pos;
|
||||||
auto length = getConvertedArgument(fn_name, pos);
|
auto length = getConvertedArgument(fn_name, pos);
|
||||||
|
|
||||||
if (startingIndex.empty())
|
if (starting_index.empty())
|
||||||
throw Exception("number of arguments do not match in function: " + fn_name, ErrorCodes::SYNTAX_ERROR);
|
throw Exception("number of arguments do not match in function: " + fn_name, ErrorCodes::SYNTAX_ERROR);
|
||||||
else
|
else
|
||||||
out = "if(toInt64(length(" + source + ")) <= 0, '', substr(" + source + ", " + "((" + startingIndex + "% toInt64(length("
|
out = "if(toInt64(length(" + source + ")) <= 0, '', substr(" + source + ", " + "((" + starting_index + "% toInt64(length("
|
||||||
+ source + ")) + toInt64(length(" + source + "))) % toInt64(length(" + source + "))) + 1, " + length + ") )";
|
+ source + ")) + toInt64(length(" + source + "))) % toInt64(length(" + source + "))) + 1, " + length + ") )";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
out = "if(toInt64(length(" + source + ")) <= 0, '', substr(" + source + "," + "((" + startingIndex + "% toInt64(length(" + source
|
out = "if(toInt64(length(" + source + ")) <= 0, '', substr(" + source + "," + "((" + starting_index + "% toInt64(length(" + source
|
||||||
+ ")) + toInt64(length(" + source + "))) % toInt64(length(" + source + "))) + 1))";
|
+ ")) + toInt64(length(" + source + "))) % toInt64(length(" + source + "))) + 1))";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include <Parsers/ExpressionListParsers.h>
|
#include <Parsers/ExpressionListParsers.h>
|
||||||
#include <Parsers/IParserBase.h>
|
#include <Parsers/IParserBase.h>
|
||||||
#include <Parsers/Kusto/ParserKQLDateTypeTimespan.h>
|
#include <Parsers/Kusto/ParserKQLDateTypeTimespan.h>
|
||||||
@ -52,7 +52,7 @@ double ParserKQLDateTypeTimespan ::toSeconds()
|
|||||||
|
|
||||||
bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
||||||
{
|
{
|
||||||
std::unordered_map<String, KQLTimespanUint> TimespanSuffixes
|
std::unordered_map<String, KQLTimespanUint> timespan_suffixes
|
||||||
= {{"d", KQLTimespanUint::day},
|
= {{"d", KQLTimespanUint::day},
|
||||||
{"day", KQLTimespanUint::day},
|
{"day", KQLTimespanUint::day},
|
||||||
{"days", KQLTimespanUint::day},
|
{"days", KQLTimespanUint::day},
|
||||||
@ -94,9 +94,9 @@ bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
|||||||
const char * ptr = text.c_str();
|
const char * ptr = text.c_str();
|
||||||
bool sign = false;
|
bool sign = false;
|
||||||
|
|
||||||
auto scanDigit = [&](const char * start) -> int
|
auto scan_digit = [&](const char * start) -> int
|
||||||
{
|
{
|
||||||
auto index = start;
|
const auto * index = start;
|
||||||
while (isdigit(*index))
|
while (isdigit(*index))
|
||||||
++index;
|
++index;
|
||||||
return index > start ? static_cast<int>(index - start) : -1;
|
return index > start ? static_cast<int>(index - start) : -1;
|
||||||
@ -106,7 +106,7 @@ bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
|||||||
sign = true;
|
sign = true;
|
||||||
++ptr;
|
++ptr;
|
||||||
}
|
}
|
||||||
auto number_len = scanDigit(ptr);
|
auto number_len = scan_digit(ptr);
|
||||||
if (number_len <= 0)
|
if (number_len <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -114,11 +114,11 @@ bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
|||||||
|
|
||||||
if (*(ptr + number_len) == '.')
|
if (*(ptr + number_len) == '.')
|
||||||
{
|
{
|
||||||
auto fractionLen = scanDigit(ptr + number_len + 1);
|
auto fraction_len = scan_digit(ptr + number_len + 1);
|
||||||
if (fractionLen >= 0)
|
if (fraction_len >= 0)
|
||||||
{
|
{
|
||||||
hours = std::stoi(String(ptr + number_len + 1, ptr + number_len + 1 + fractionLen));
|
hours = std::stoi(String(ptr + number_len + 1, ptr + number_len + 1 + fraction_len));
|
||||||
number_len += fractionLen + 1;
|
number_len += fraction_len + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*(ptr + number_len) == '\0')
|
else if (*(ptr + number_len) == '\0')
|
||||||
@ -142,11 +142,11 @@ bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
|||||||
String timespan_suffix(ptr + number_len, ptr + text.size());
|
String timespan_suffix(ptr + number_len, ptr + text.size());
|
||||||
|
|
||||||
trim(timespan_suffix);
|
trim(timespan_suffix);
|
||||||
if (TimespanSuffixes.find(timespan_suffix) == TimespanSuffixes.end())
|
if (timespan_suffixes.find(timespan_suffix) == timespan_suffixes.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
time_span = std::stod(String(ptr, ptr + number_len));
|
time_span = std::stod(String(ptr, ptr + number_len));
|
||||||
time_span_unit = TimespanSuffixes[timespan_suffix];
|
time_span_unit = timespan_suffixes[timespan_suffix];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
|||||||
if (hours > 23)
|
if (hours > 23)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto min_len = scanDigit(ptr + number_len + 1);
|
auto min_len = scan_digit(ptr + number_len + 1);
|
||||||
if (min_len < 0)
|
if (min_len < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
|||||||
number_len += min_len + 1;
|
number_len += min_len + 1;
|
||||||
if (*(ptr + number_len) == ':')
|
if (*(ptr + number_len) == ':')
|
||||||
{
|
{
|
||||||
auto sec_len = scanDigit(ptr + number_len + 1);
|
auto sec_len = scan_digit(ptr + number_len + 1);
|
||||||
if (sec_len > 0)
|
if (sec_len > 0)
|
||||||
{
|
{
|
||||||
seconds = std::stoi(String(ptr + number_len + 1, ptr + number_len + 1 + sec_len));
|
seconds = std::stoi(String(ptr + number_len + 1, ptr + number_len + 1 + sec_len));
|
||||||
@ -175,7 +175,7 @@ bool ParserKQLDateTypeTimespan ::parseConstKQLTimespan(const String & text)
|
|||||||
number_len += sec_len + 1;
|
number_len += sec_len + 1;
|
||||||
if (*(ptr + number_len) == '.')
|
if (*(ptr + number_len) == '.')
|
||||||
{
|
{
|
||||||
sec_scale_len = scanDigit(ptr + number_len + 1);
|
sec_scale_len = scan_digit(ptr + number_len + 1);
|
||||||
if (sec_scale_len > 0)
|
if (sec_scale_len > 0)
|
||||||
{
|
{
|
||||||
nanoseconds = std::stoi(String(ptr + number_len + 1, ptr + number_len + 1 + sec_scale_len));
|
nanoseconds = std::stoi(String(ptr + number_len + 1, ptr + number_len + 1 + sec_scale_len));
|
||||||
|
@ -66,7 +66,7 @@ bool ParserKQLMVExpand::parseColumnArrayExprs(ColumnArrayExprs & column_array_ex
|
|||||||
expr_begin_pos = pos;
|
expr_begin_pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto addColumns = [&]
|
auto add_columns = [&]
|
||||||
{
|
{
|
||||||
column_array_expr = getExprFromToken(String(expr_begin_pos->begin, expr_end_pos->end), pos.max_depth);
|
column_array_expr = getExprFromToken(String(expr_begin_pos->begin, expr_end_pos->end), pos.max_depth);
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ bool ParserKQLMVExpand::parseColumnArrayExprs(ColumnArrayExprs & column_array_ex
|
|||||||
expr_end_pos = pos;
|
expr_end_pos = pos;
|
||||||
--expr_end_pos;
|
--expr_end_pos;
|
||||||
}
|
}
|
||||||
addColumns();
|
add_columns();
|
||||||
expr_begin_pos = pos;
|
expr_begin_pos = pos;
|
||||||
expr_end_pos = pos;
|
expr_end_pos = pos;
|
||||||
++expr_begin_pos;
|
++expr_begin_pos;
|
||||||
@ -133,7 +133,7 @@ bool ParserKQLMVExpand::parseColumnArrayExprs(ColumnArrayExprs & column_array_ex
|
|||||||
expr_end_pos = pos;
|
expr_end_pos = pos;
|
||||||
--expr_end_pos;
|
--expr_end_pos;
|
||||||
}
|
}
|
||||||
addColumns();
|
add_columns();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ bool ParserKQLMakeSeries ::makeSeries(KQLMakeSeries & kql_make_series, ASTPtr &
|
|||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
String res;
|
String res;
|
||||||
for (auto token : group_expression_tokens)
|
for (auto const & token : group_expression_tokens)
|
||||||
res = res + token + " ";
|
res = res + token + " ";
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -42,9 +42,9 @@ protected:
|
|||||||
String main_query;
|
String main_query;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool makeSeries(KQLMakeSeries & kql_make_series, ASTPtr & select_node, const uint32_t & max_depth);
|
static bool makeSeries(KQLMakeSeries & kql_make_series, ASTPtr & select_node, const uint32_t & max_depth);
|
||||||
bool parseAggregationColumns(AggregationColumns & aggregation_columns, Pos & pos);
|
static bool parseAggregationColumns(AggregationColumns & aggregation_columns, Pos & pos);
|
||||||
bool parseFromToStepClause(FromToStepClause & from_to_step, Pos & pos);
|
static bool parseFromToStepClause(FromToStepClause & from_to_step, Pos & pos);
|
||||||
|
|
||||||
const char * getName() const override { return "KQL make-series"; }
|
const char * getName() const override { return "KQL make-series"; }
|
||||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||||
|
@ -197,7 +197,7 @@ String ParserKQLBase::getExprFromToken(Pos & pos)
|
|||||||
tokens.push_back(alias);
|
tokens.push_back(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto token : tokens)
|
for (auto const & token : tokens)
|
||||||
res = res.empty() ? token : res + " " + token;
|
res = res.empty() ? token : res + " " + token;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -174,10 +174,10 @@ bool ParserKQLSummarize::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
|
|||||||
--pos;
|
--pos;
|
||||||
apply_aliais(column_begin_pos, pos, groupby);
|
apply_aliais(column_begin_pos, pos, groupby);
|
||||||
|
|
||||||
for (auto expr : expr_aggregations)
|
for (auto const & expr : expr_aggregations)
|
||||||
expr_aggregation = expr_aggregation.empty() ? expr : expr_aggregation + "," + expr;
|
expr_aggregation = expr_aggregation.empty() ? expr : expr_aggregation + "," + expr;
|
||||||
|
|
||||||
for (auto expr : expr_groupbys)
|
for (auto const & expr : expr_groupbys)
|
||||||
expr_groupby = expr_groupby.empty() ? expr : expr_groupby + "," + expr;
|
expr_groupby = expr_groupby.empty() ? expr : expr_groupby + "," + expr;
|
||||||
|
|
||||||
if (!expr_groupby.empty())
|
if (!expr_groupby.empty())
|
||||||
|
@ -57,17 +57,17 @@ Customers | summarize job_count = count() by Occupation | where job_count > 0;
|
|||||||
Customers | summarize 'Edu Count'=count() by Education | sort by 'Edu Count' desc; -- { clientError 62 }
|
Customers | summarize 'Edu Count'=count() by Education | sort by 'Edu Count' desc; -- { clientError 62 }
|
||||||
|
|
||||||
print '-- make_list() --';
|
print '-- make_list() --';
|
||||||
Customers | summarize f_list = make_list(Education) by Occupation;
|
Customers | summarize f_list = make_list(Education) by Occupation | sort by Occupation;
|
||||||
Customers | summarize f_list = make_list(Education, 2) by Occupation;
|
Customers | summarize f_list = make_list(Education, 2) by Occupation | sort by Occupation;
|
||||||
print '-- make_list_if() --';
|
print '-- make_list_if() --';
|
||||||
Customers | summarize f_list = make_list_if(FirstName, Age>30) by Occupation;
|
Customers | summarize f_list = make_list_if(FirstName, Age>30) by Occupation | sort by Occupation;
|
||||||
Customers | summarize f_list = make_list_if(FirstName, Age>30, 1) by Occupation;
|
Customers | summarize f_list = make_list_if(FirstName, Age>30, 1) by Occupation | sort by Occupation;
|
||||||
print '-- make_set() --';
|
print '-- make_set() --';
|
||||||
Customers | summarize f_list = make_set(Education) by Occupation;
|
Customers | summarize f_list = make_set(Education) by Occupation | sort by Occupation;
|
||||||
Customers | summarize f_list = make_set(Education, 2) by Occupation;
|
Customers | summarize f_list = make_set(Education, 2) by Occupation | sort by Occupation;
|
||||||
print '-- make_set_if() --';
|
print '-- make_set_if() --';
|
||||||
Customers | summarize f_list = make_set_if(Education, Age>30) by Occupation;
|
Customers | summarize f_list = make_set_if(Education, Age>30) by Occupation | sort by Occupation;
|
||||||
Customers | summarize f_list = make_set_if(Education, Age>30, 1) by Occupation;
|
Customers | summarize f_list = make_set_if(Education, Age>30, 1) by Occupation | sort by Occupation;
|
||||||
print '-- stdev() --';
|
print '-- stdev() --';
|
||||||
Customers | project Age | summarize stdev(Age);
|
Customers | project Age | summarize stdev(Age);
|
||||||
print '-- stdevif() --';
|
print '-- stdevif() --';
|
||||||
|
Loading…
Reference in New Issue
Block a user