From eb3534d0d25a27f9b4a8de7fba91170b9d7796b5 Mon Sep 17 00:00:00 2001 From: ltrk2 <107155950+ltrk2@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:17:05 -0700 Subject: [PATCH] Use an associative container instead of an array --- src/Parsers/Kusto/KustoFunctions/KQLDataTypeFunctions.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Parsers/Kusto/KustoFunctions/KQLDataTypeFunctions.cpp b/src/Parsers/Kusto/KustoFunctions/KQLDataTypeFunctions.cpp index ae7d398ee56c..69b4e75b8574 100644 --- a/src/Parsers/Kusto/KustoFunctions/KQLDataTypeFunctions.cpp +++ b/src/Parsers/Kusto/KustoFunctions/KQLDataTypeFunctions.cpp @@ -8,7 +8,6 @@ #include #include -#include #include namespace DB @@ -55,8 +54,8 @@ bool DatatypeDatetime::convertImpl(String & out, IParser::Pos & pos) bool DatatypeDynamic::convertImpl(String & out, IParser::Pos & pos) { - static constexpr std::array ALLOWED_KEYWORDS - = {"date", "datetime", "dynamic", "false", "null", "time", "timespan", "true"}; + static const std::unordered_set ALLOWED_KEYWORDS{ + "date", "datetime", "dynamic", "false", "null", "time", "timespan", "true"}; const auto function_name = getKQLFunctionName(pos); if (function_name.empty()) @@ -71,8 +70,7 @@ bool DatatypeDynamic::convertImpl(String & out, IParser::Pos & pos) if (const auto token_type = pos->type; token_type == TokenType::BareWord || token_type == TokenType::Number || token_type == TokenType::QuotedIdentifier || token_type == TokenType::StringLiteral) { - if (const std::string_view token(pos->begin, pos->end); token_type == TokenType::BareWord - && std::find(std::cbegin(ALLOWED_KEYWORDS), std::cend(ALLOWED_KEYWORDS), token) == std::cend(ALLOWED_KEYWORDS)) + if (const std::string_view token(pos->begin, pos->end); token_type == TokenType::BareWord && !ALLOWED_KEYWORDS.contains(token)) throw Exception(ErrorCodes::SYNTAX_ERROR, "Expression {} is not supported inside {}", token, function_name); out.append(getConvertedArgument(function_name, pos));