Apply linter changes

This commit is contained in:
Konstantin Bogdanov 2024-09-19 13:51:02 +02:00
parent ce4d88851a
commit 67c1e89d90
Signed by: thevar1able
GPG Key ID: DB399448D9FE52F1
802 changed files with 6604 additions and 7807 deletions

View File

@ -116,7 +116,6 @@ Checks: [
'-readability-avoid-unconditional-preprocessor-if', '-readability-avoid-unconditional-preprocessor-if',
'-readability-braces-around-statements', '-readability-braces-around-statements',
'-readability-convert-member-functions-to-static', '-readability-convert-member-functions-to-static',
'-readability-else-after-return',
'-readability-function-cognitive-complexity', '-readability-function-cognitive-complexity',
'-readability-function-size', '-readability-function-size',
'-readability-identifier-length', '-readability-identifier-length',

View File

@ -110,7 +110,6 @@ struct DecomposedFloat
{ {
if (!isNegative()) if (!isNegative())
return rhs > 0 ? -1 : 1; return rhs > 0 ? -1 : 1;
else
return rhs >= 0 ? -1 : 1; return rhs >= 0 ? -1 : 1;
} }
@ -128,7 +127,6 @@ struct DecomposedFloat
if (mantissa() == 0) if (mantissa() == 0)
return 0; return 0;
else
return -1; return -1;
} }
} }
@ -169,7 +167,6 @@ struct DecomposedFloat
/// Float has no fractional part means that the numbers are equal. /// Float has no fractional part means that the numbers are equal.
if (large_and_always_integer || (mantissa() & ((1ULL << (Traits::mantissa_bits - normalizedExponent())) - 1)) == 0) if (large_and_always_integer || (mantissa() & ((1ULL << (Traits::mantissa_bits - normalizedExponent())) - 1)) == 0)
return 0; return 0;
else
/// Float has fractional part means its abs value is larger. /// Float has fractional part means its abs value is larger.
return isNegative() ? -1 : 1; return isNegative() ? -1 : 1;
} }

View File

@ -205,7 +205,6 @@ JSON::ElementType JSON::getType() const
Pos after_string = skipString(); Pos after_string = skipString();
if (after_string < ptr_end && *after_string == ':') if (after_string < ptr_end && *after_string == ':')
return TYPE_NAME_VALUE_PAIR; return TYPE_NAME_VALUE_PAIR;
else
return TYPE_STRING; return TYPE_STRING;
} }
default: default:
@ -474,7 +473,6 @@ JSON::Pos JSON::searchField(const char * data, size_t size) const
if (it == end()) if (it == end())
return nullptr; return nullptr;
else
return it->data(); return it->data();
} }
@ -487,7 +485,7 @@ bool JSON::hasEscapes() const
if (*pos == '"') if (*pos == '"')
return false; return false;
else if (*pos == '\\') if (*pos == '\\')
return true; return true;
throw JSONException("JSON: unexpected end of data."); throw JSONException("JSON: unexpected end of data.");
} }
@ -503,7 +501,7 @@ bool JSON::hasSpecialChars() const
if (*pos == '"') if (*pos == '"')
return false; return false;
else if (pos < ptr_end) if (pos < ptr_end)
return true; return true;
throw JSONException("JSON: unexpected end of data."); throw JSONException("JSON: unexpected end of data.");
} }
@ -682,9 +680,8 @@ double JSON::toDouble() const
if (type == TYPE_NUMBER) if (type == TYPE_NUMBER)
return getDouble(); return getDouble();
else if (type == TYPE_STRING) if (type == TYPE_STRING)
return JSON(ptr_begin + 1, ptr_end, level + 1).getDouble(); return JSON(ptr_begin + 1, ptr_end, level + 1).getDouble();
else
throw JSONException("JSON: cannot convert value to double."); throw JSONException("JSON: cannot convert value to double.");
} }
@ -694,9 +691,8 @@ Int64 JSON::toInt() const
if (type == TYPE_NUMBER) if (type == TYPE_NUMBER)
return getInt(); return getInt();
else if (type == TYPE_STRING) if (type == TYPE_STRING)
return JSON(ptr_begin + 1, ptr_end, level + 1).getInt(); return JSON(ptr_begin + 1, ptr_end, level + 1).getInt();
else
throw JSONException("JSON: cannot convert value to signed integer."); throw JSONException("JSON: cannot convert value to signed integer.");
} }
@ -706,9 +702,8 @@ UInt64 JSON::toUInt() const
if (type == TYPE_NUMBER) if (type == TYPE_NUMBER)
return getUInt(); return getUInt();
else if (type == TYPE_STRING) if (type == TYPE_STRING)
return JSON(ptr_begin + 1, ptr_end, level + 1).getUInt(); return JSON(ptr_begin + 1, ptr_end, level + 1).getUInt();
else
throw JSONException("JSON: cannot convert value to unsigned integer."); throw JSONException("JSON: cannot convert value to unsigned integer.");
} }
@ -718,12 +713,10 @@ std::string JSON::toString() const
if (type == TYPE_STRING) if (type == TYPE_STRING)
return getString(); return getString();
else
{
Pos pos = skipElement(); Pos pos = skipElement();
return std::string(ptr_begin, pos - ptr_begin); return std::string(ptr_begin, pos - ptr_begin);
} }
}
JSON::iterator JSON::iterator::begin() const JSON::iterator JSON::iterator::begin() const

View File

@ -203,9 +203,7 @@ T JSON::getWithDefault(const std::string & key, const T & default_) const
if (key_json.isType<T>()) if (key_json.isType<T>())
return key_json.get<T>(); return key_json.get<T>();
else
return default_; return default_;
} }
else
return default_; return default_;
} }

View File

@ -151,19 +151,19 @@ inline bool memequalWide(const char * p1, const char * p2, size_t size)
return unalignedLoad<uint64_t>(p1) == unalignedLoad<uint64_t>(p2) return unalignedLoad<uint64_t>(p1) == unalignedLoad<uint64_t>(p2)
&& unalignedLoad<uint64_t>(p1 + size - 8) == unalignedLoad<uint64_t>(p2 + size - 8); && unalignedLoad<uint64_t>(p1 + size - 8) == unalignedLoad<uint64_t>(p2 + size - 8);
} }
else if (size >= 4) if (size >= 4)
{ {
/// Chunks of 4..7 bytes. /// Chunks of 4..7 bytes.
return unalignedLoad<uint32_t>(p1) == unalignedLoad<uint32_t>(p2) return unalignedLoad<uint32_t>(p1) == unalignedLoad<uint32_t>(p2)
&& unalignedLoad<uint32_t>(p1 + size - 4) == unalignedLoad<uint32_t>(p2 + size - 4); && unalignedLoad<uint32_t>(p1 + size - 4) == unalignedLoad<uint32_t>(p2 + size - 4);
} }
else if (size >= 2) if (size >= 2)
{ {
/// Chunks of 2..3 bytes. /// Chunks of 2..3 bytes.
return unalignedLoad<uint16_t>(p1) == unalignedLoad<uint16_t>(p2) return unalignedLoad<uint16_t>(p1) == unalignedLoad<uint16_t>(p2)
&& unalignedLoad<uint16_t>(p1 + size - 2) == unalignedLoad<uint16_t>(p2 + size - 2); && unalignedLoad<uint16_t>(p1 + size - 2) == unalignedLoad<uint16_t>(p2 + size - 2);
} }
else if (size >= 1) if (size >= 1)
{ {
/// A single byte. /// A single byte.
return *p1 == *p2; return *p1 == *p2;

View File

@ -53,10 +53,9 @@ void argsToConfig(const Poco::Util::Application::ArgVec & argv,
key = arg.substr(key_start); key = arg.substr(key_start);
continue; continue;
} }
else
{
key = ""; key = "";
}
if (key_start == std::string::npos) if (key_start == std::string::npos)
continue; continue;

View File

@ -330,7 +330,6 @@ inline const char * find_first_symbols_dispatch(const char * begin, const char *
#if defined(__SSE4_2__) #if defined(__SSE4_2__)
if (sizeof...(symbols) >= 5) if (sizeof...(symbols) >= 5)
return find_first_symbols_sse42<positive, return_mode, sizeof...(symbols), symbols...>(begin, end); return find_first_symbols_sse42<positive, return_mode, sizeof...(symbols), symbols...>(begin, end);
else
#endif #endif
return find_first_symbols_sse2<positive, return_mode, symbols...>(begin, end); return find_first_symbols_sse2<positive, return_mode, symbols...>(begin, end);
} }
@ -341,7 +340,6 @@ inline const char * find_first_symbols_dispatch(const std::string_view haystack,
#if defined(__SSE4_2__) #if defined(__SSE4_2__)
if (symbols.str.size() >= 5) if (symbols.str.size() >= 5)
return find_first_symbols_sse42<positive, return_mode>(haystack.begin(), haystack.end(), symbols); return find_first_symbols_sse42<positive, return_mode>(haystack.begin(), haystack.end(), symbols);
else
#endif #endif
return find_first_symbols_sse2<positive, return_mode>(haystack.begin(), haystack.end(), symbols.str.data(), symbols.str.size()); return find_first_symbols_sse2<positive, return_mode>(haystack.begin(), haystack.end(), symbols.str.data(), symbols.str.size());
} }

View File

@ -33,7 +33,6 @@ std::optional<uint64_t> getCgroupsV2MemoryLimit()
uint64_t value; uint64_t value;
if (setting_file >> value) if (setting_file >> value)
return {value}; return {value};
else
return {}; /// e.g. the cgroups default "max" return {}; /// e.g. the cgroups default "max"
} }
current_cgroup = current_cgroup.parent_path(); current_cgroup = current_cgroup.parent_path();

View File

@ -445,8 +445,7 @@ private:
shutdown = true; shutdown = true;
throw; throw;
} }
else
{
std::cerr << getCurrentExceptionMessage(print_stacktrace, std::cerr << getCurrentExceptionMessage(print_stacktrace,
true /*check embedded stack trace*/) << std::endl; true /*check embedded stack trace*/) << std::endl;
@ -454,7 +453,6 @@ private:
++comparison_info_per_interval[info_index]->errors; ++comparison_info_per_interval[info_index]->errors;
++comparison_info_total[info_index]->errors; ++comparison_info_total[info_index]->errors;
} }
}
// Count failed queries toward executed, so that we'd reach // Count failed queries toward executed, so that we'd reach
// max_iterations even if every run fails. // max_iterations even if every run fails.
++queries_executed; ++queries_executed;

View File

@ -479,14 +479,11 @@ void Client::connect()
break; break;
} }
catch (const Exception & e) catch (const Exception & e)
{
if (e.code() == DB::ErrorCodes::AUTHENTICATION_FAILED)
{ {
/// This problem can't be fixed with reconnection so it is not attempted /// This problem can't be fixed with reconnection so it is not attempted
if (e.code() == DB::ErrorCodes::AUTHENTICATION_FAILED)
throw; throw;
}
else
{
if (attempted_address_index == hosts_and_ports.size() - 1) if (attempted_address_index == hosts_and_ports.size() - 1)
throw; throw;
@ -503,7 +500,6 @@ void Client::connect()
} }
} }
} }
}
server_version = toString(server_version_major) + "." + toString(server_version_minor) + "." + toString(server_version_patch); server_version = toString(server_version_major) + "." + toString(server_version_minor) + "." + toString(server_version_patch);
load_suggestions = is_interactive && (server_revision >= Suggest::MIN_SERVER_REVISION) && !config().getBool("disable_suggestion", false); load_suggestions = is_interactive && (server_revision >= Suggest::MIN_SERVER_REVISION) && !config().getBool("disable_suggestion", false);

View File

@ -46,7 +46,7 @@ public:
path_from, path_from,
disk_from.getDisk()->getName()); disk_from.getDisk()->getName());
} }
else if (disk_from.getDisk()->isFile(path_from)) if (disk_from.getDisk()->isFile(path_from))
{ {
auto target_location = getTargetLocation(path_from, disk_to, path_to); auto target_location = getTargetLocation(path_from, disk_to, path_to);
if (!disk_to.getDisk()->exists(target_location) || disk_to.getDisk()->isFile(target_location)) if (!disk_to.getDisk()->exists(target_location) || disk_to.getDisk()->isFile(target_location))
@ -77,7 +77,7 @@ public:
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot overwrite non-directory {} with directory {}", path_to, target_location); throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot overwrite non-directory {} with directory {}", path_to, target_location);
} }
else if (!disk_to.getDisk()->exists(target_location)) if (!disk_to.getDisk()->exists(target_location))
{ {
disk_to.getDisk()->createDirectory(target_location); disk_to.getDisk()->createDirectory(target_location);
} }

View File

@ -72,13 +72,9 @@ private:
auto path = [&]() -> String auto path = [&]() -> String
{ {
if (relative_path.ends_with("/")) if (relative_path.ends_with("/"))
{
return relative_path + file_name; return relative_path + file_name;
}
else
{
return relative_path + "/" + file_name; return relative_path + "/" + file_name;
}
}(); }();
if (disk.isDirectory(path)) if (disk.isDirectory(path))
{ {

View File

@ -53,12 +53,10 @@ public:
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot move '{}' to '{}': Directory not empty", path_from, target_location); throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot move '{}' to '{}': Directory not empty", path_from, target_location);
} }
else
{
disk.getDisk()->moveDirectory(path_from, target_location); disk.getDisk()->moveDirectory(path_from, target_location);
} }
} }
}
else if (!disk.getDisk()->exists(path_from)) else if (!disk.getDisk()->exists(path_from))
{ {
throw Exception( throw Exception(

View File

@ -32,17 +32,15 @@ public:
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Path {} on disk {} doesn't exist", path, disk.getDisk()->getName()); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Path {} on disk {} doesn't exist", path, disk.getDisk()->getName());
} }
else if (disk.getDisk()->isDirectory(path)) if (disk.getDisk()->isDirectory(path))
{ {
if (!recursive) if (!recursive)
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot remove '{}': Is a directory", path); throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot remove '{}': Is a directory", path);
} }
else
{
disk.getDisk()->removeRecursive(path); disk.getDisk()->removeRecursive(path);
} }
}
else else
{ {
disk.getDisk()->removeFileIfExists(path); disk.getDisk()->removeFileIfExists(path);

View File

@ -33,14 +33,10 @@ public:
auto in = [&]() -> std::unique_ptr<ReadBufferFromFileBase> auto in = [&]() -> std::unique_ptr<ReadBufferFromFileBase>
{ {
if (!path_from.has_value()) if (!path_from.has_value())
{
return std::make_unique<ReadBufferFromFileDescriptor>(STDIN_FILENO); return std::make_unique<ReadBufferFromFileDescriptor>(STDIN_FILENO);
}
else
{
String relative_path_from = disk.getRelativeFromRoot(path_from.value()); String relative_path_from = disk.getRelativeFromRoot(path_from.value());
return disk.getDisk()->readFile(relative_path_from, getReadSettings()); return disk.getDisk()->readFile(relative_path_from, getReadSettings());
}
}(); }();
auto out = disk.getDisk()->writeFile(path_to); auto out = disk.getDisk()->writeFile(path_to);

View File

@ -127,13 +127,12 @@ std::vector<String> DisksApp::getCompletions(const String & prefix) const
} }
return getEmptyCompletion(command->command_name); return getEmptyCompletion(command->command_name);
} }
else if (arguments.size() == 1) if (arguments.size() == 1)
{ {
String command_prefix = arguments[0]; String command_prefix = arguments[0];
return getCommandsToComplete(command_prefix); return getCommandsToComplete(command_prefix);
} }
else
{
String last_token = arguments.back(); String last_token = arguments.back();
CommandPtr command; CommandPtr command;
try try
@ -144,23 +143,17 @@ std::vector<String> DisksApp::getCompletions(const String & prefix) const
{ {
return {last_token}; return {last_token};
} }
std::vector<String> answer = {}; std::vector<String> answer = {};
if (command->command_name == "help") if (command->command_name == "help")
{
return getCommandsToComplete(last_token); return getCommandsToComplete(last_token);
}
else
{
answer = [&]() -> std::vector<String> answer = [&]() -> std::vector<String>
{ {
if (multidisk_commands.contains(command->command_name)) if (multidisk_commands.contains(command->command_name))
{
return client->getAllFilesByPatternFromAllDisks(last_token); return client->getAllFilesByPatternFromAllDisks(last_token);
}
else
{
return client->getCurrentDiskWithPath().getAllFilesByPattern(last_token); return client->getCurrentDiskWithPath().getAllFilesByPattern(last_token);
}
}(); }();
for (const auto & disk_name : client->getAllDiskNames()) for (const auto & disk_name : client->getAllDiskNames())
@ -178,18 +171,15 @@ std::vector<String> DisksApp::getCompletions(const String & prefix) const
answer.push_back(option_sign); answer.push_back(option_sign);
} }
} }
}
if (!answer.empty()) if (!answer.empty())
{ {
std::sort(answer.begin(), answer.end()); std::sort(answer.begin(), answer.end());
return answer; return answer;
} }
else
{
return {last_token}; return {last_token};
} }
}
}
bool DisksApp::processQueryText(const String & text) bool DisksApp::processQueryText(const String & text)
{ {
@ -210,11 +200,11 @@ bool DisksApp::processQueryText(const String & text)
catch (DB::Exception & err) catch (DB::Exception & err)
{ {
int code = getCurrentExceptionCode(); int code = getCurrentExceptionCode();
if (code == ErrorCodes::LOGICAL_ERROR) if (code == ErrorCodes::LOGICAL_ERROR)
{
throw std::move(err); throw std::move(err);
}
else if (code == ErrorCodes::BAD_ARGUMENTS) if (code == ErrorCodes::BAD_ARGUMENTS)
{ {
std::cerr << err.message() << "\n" std::cerr << err.message() << "\n"
<< "\n"; << "\n";

View File

@ -49,11 +49,9 @@ std::vector<String> DiskWithPath::listAllFilesByPath(const String & any_path) co
disk->listFiles(getRelativeFromRoot(any_path), file_names); disk->listFiles(getRelativeFromRoot(any_path), file_names);
return file_names; return file_names;
} }
else
{
return {}; return {};
} }
}
std::vector<String> DiskWithPath::getAllFilesByPattern(const String & pattern) const std::vector<String> DiskWithPath::getAllFilesByPattern(const String & pattern) const
{ {
@ -61,23 +59,15 @@ std::vector<String> DiskWithPath::getAllFilesByPattern(const String & pattern) c
{ {
auto slash_pos = pattern.find_last_of('/'); auto slash_pos = pattern.find_last_of('/');
if (slash_pos >= pattern.size()) if (slash_pos >= pattern.size())
{
return {"", pattern}; return {"", pattern};
}
else
{
return {pattern.substr(0, slash_pos + 1), pattern.substr(slash_pos + 1, pattern.size() - slash_pos - 1)}; return {pattern.substr(0, slash_pos + 1), pattern.substr(slash_pos + 1, pattern.size() - slash_pos - 1)};
}
}(); }();
if (!isDirectory(path_before)) if (!isDirectory(path_before))
{
return {}; return {};
}
else
{
std::vector<String> file_names = listAllFilesByPath(path_before);
std::vector<String> file_names = listAllFilesByPath(path_before);
std::vector<String> answer; std::vector<String> answer;
for (const auto & file_name : file_names) for (const auto & file_name : file_names)
@ -93,7 +83,6 @@ std::vector<String> DiskWithPath::getAllFilesByPattern(const String & pattern) c
} }
} }
return answer; return answer;
}
}; };
void DiskWithPath::setPath(const String & any_path) void DiskWithPath::setPath(const String & any_path)

View File

@ -39,13 +39,9 @@ DiskWithPath & ICommand::getDiskWithPath(DisksClient & client, const CommandLine
{ {
auto disk_name = getValueFromCommandLineOptionsWithOptional<String>(options, name); auto disk_name = getValueFromCommandLineOptionsWithOptional<String>(options, name);
if (disk_name.has_value()) if (disk_name.has_value())
{
return client.getDiskWithPath(disk_name.value()); return client.getDiskWithPath(disk_name.value());
}
else
{
return client.getCurrentDiskWithPath(); return client.getCurrentDiskWithPath();
} }
}
} }

View File

@ -63,40 +63,28 @@ protected:
static T getValueFromCommandLineOptionsThrow(const CommandLineOptions & options, const String & name) static T getValueFromCommandLineOptionsThrow(const CommandLineOptions & options, const String & name)
{ {
if (options.count(name)) if (options.count(name))
{
return getValueFromCommandLineOptions<T>(options, name); return getValueFromCommandLineOptions<T>(options, name);
}
else
{
throw DB::Exception(ErrorCodes::BAD_ARGUMENTS, "Mandatory argument '{}' is missing", name); throw DB::Exception(ErrorCodes::BAD_ARGUMENTS, "Mandatory argument '{}' is missing", name);
} }
}
template <typename T> template <typename T>
static T getValueFromCommandLineOptionsWithDefault(const CommandLineOptions & options, const String & name, const T & default_value) static T getValueFromCommandLineOptionsWithDefault(const CommandLineOptions & options, const String & name, const T & default_value)
{ {
if (options.count(name)) if (options.count(name))
{
return getValueFromCommandLineOptions<T>(options, name); return getValueFromCommandLineOptions<T>(options, name);
}
else
{
return default_value; return default_value;
} }
}
template <typename T> template <typename T>
static std::optional<T> getValueFromCommandLineOptionsWithOptional(const CommandLineOptions & options, const String & name) static std::optional<T> getValueFromCommandLineOptionsWithOptional(const CommandLineOptions & options, const String & name)
{ {
if (options.count(name)) if (options.count(name))
{
return std::optional{getValueFromCommandLineOptions<T>(options, name)}; return std::optional{getValueFromCommandLineOptions<T>(options, name)};
}
else
{
return std::nullopt; return std::nullopt;
} }
}
DiskWithPath & getDiskWithPath(DisksClient & client, const CommandLineOptions & options, const String & name); DiskWithPath & getDiskWithPath(DisksClient & client, const CommandLineOptions & options, const String & name);

View File

@ -110,7 +110,7 @@ static auto executeScript(const std::string & command, bool throw_on_error = fal
sh->wait(); sh->wait();
return 0; return 0;
} }
else
return sh->tryWait(); return sh->tryWait();
} }

View File

@ -26,8 +26,7 @@ CatBoostLibraryHandlerPtr CatBoostLibraryHandlerFactory::tryGetModel(const Strin
if (found) if (found)
return handler->second; return handler->second;
else
{
if (create_if_not_found) if (create_if_not_found)
{ {
auto new_handler = std::make_shared<CatBoostLibraryHandler>(library_path, model_path); auto new_handler = std::make_shared<CatBoostLibraryHandler>(library_path, model_path);
@ -37,7 +36,6 @@ CatBoostLibraryHandlerPtr CatBoostLibraryHandlerFactory::tryGetModel(const Strin
} }
return nullptr; return nullptr;
} }
}
void CatBoostLibraryHandlerFactory::removeModel(const String & model_path) void CatBoostLibraryHandlerFactory::removeModel(const String & model_path)
{ {

View File

@ -25,7 +25,7 @@ std::unique_ptr<HTTPRequestHandler> LibraryBridgeHandlerFactory::createRequestHa
{ {
if (uri.getPath() == "/extdict_ping") if (uri.getPath() == "/extdict_ping")
return std::make_unique<ExternalDictionaryLibraryBridgeExistsHandler>(getContext()); return std::make_unique<ExternalDictionaryLibraryBridgeExistsHandler>(getContext());
else if (uri.getPath() == "/catboost_ping") if (uri.getPath() == "/catboost_ping")
return std::make_unique<CatBoostLibraryBridgeExistsHandler>(getContext()); return std::make_unique<CatBoostLibraryBridgeExistsHandler>(getContext());
} }
@ -33,7 +33,7 @@ std::unique_ptr<HTTPRequestHandler> LibraryBridgeHandlerFactory::createRequestHa
{ {
if (uri.getPath() == "/extdict_request") if (uri.getPath() == "/extdict_request")
return std::make_unique<ExternalDictionaryLibraryBridgeRequestHandler>(getContext()); return std::make_unique<ExternalDictionaryLibraryBridgeRequestHandler>(getContext());
else if (uri.getPath() == "/catboost_request") if (uri.getPath() == "/catboost_request")
return std::make_unique<CatBoostLibraryBridgeRequestHandler>(getContext()); return std::make_unique<CatBoostLibraryBridgeRequestHandler>(getContext());
} }

View File

@ -158,12 +158,10 @@ void ExternalDictionaryLibraryBridgeRequestHandler::handleRequest(HTTPServerRequ
out.finalize(); out.finalize();
return; return;
} }
else
{
LOG_TRACE(log, "Cannot clone from dictionary with id: {}, will call extDict_libNew instead", from_dictionary_id); LOG_TRACE(log, "Cannot clone from dictionary with id: {}, will call extDict_libNew instead", from_dictionary_id);
lib_new = true; lib_new = true;
} }
}
if (lib_new) if (lib_new)
{ {
auto & read_buf = request.getStream(); auto & read_buf = request.getStream();

View File

@ -231,7 +231,7 @@ static Int64 transformSigned(Int64 x, UInt64 seed)
{ {
if (x >= 0) if (x >= 0)
return transform(x, seed); return transform(x, seed);
else
return -transform(-x, seed); /// It works Ok even for minimum signed number. return -transform(-x, seed); /// It works Ok even for minimum signed number.
} }
@ -1105,7 +1105,7 @@ public:
{ {
if (isUInt(data_type)) if (isUInt(data_type))
return std::make_unique<UnsignedIntegerModel>(seed); return std::make_unique<UnsignedIntegerModel>(seed);
else
return std::make_unique<SignedIntegerModel>(seed); return std::make_unique<SignedIntegerModel>(seed);
} }

View File

@ -39,11 +39,11 @@ IdentifierQuotingStyle getQuotingStyle(nanodbc::ConnectionHolderPtr connection)
auto identifier_quote = getIdentifierQuote(connection); auto identifier_quote = getIdentifierQuote(connection);
if (identifier_quote.empty()) if (identifier_quote.empty())
return IdentifierQuotingStyle::Backticks; return IdentifierQuotingStyle::Backticks;
else if (identifier_quote[0] == '`') if (identifier_quote[0] == '`')
return IdentifierQuotingStyle::Backticks; return IdentifierQuotingStyle::Backticks;
else if (identifier_quote[0] == '"') if (identifier_quote[0] == '"')
return IdentifierQuotingStyle::DoubleQuotes; return IdentifierQuotingStyle::DoubleQuotes;
else
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Can not map quote identifier '{}' to IdentifierQuotingStyle value", identifier_quote); "Can not map quote identifier '{}' to IdentifierQuotingStyle value", identifier_quote);
} }

View File

@ -127,7 +127,7 @@ std::string validateODBCConnectionString(const std::string & connection_string)
if (*pos == '{') if (*pos == '{')
return read_escaped_value(); return read_escaped_value();
else
return read_plain_value(); return read_plain_value();
}; };
@ -206,13 +206,11 @@ std::string validateODBCConnectionString(const std::string & connection_string)
reconstructed_connection_string.append(value_pos, next_pos - value_pos); reconstructed_connection_string.append(value_pos, next_pos - value_pos);
break; break;
} }
else
{
reconstructed_connection_string.append(value_pos, next_pos - value_pos); reconstructed_connection_string.append(value_pos, next_pos - value_pos);
reconstructed_connection_string.append("}}"); reconstructed_connection_string.append("}}");
value_pos = next_pos + 1; value_pos = next_pos + 1;
} }
}
reconstructed_connection_string += '}'; reconstructed_connection_string += '}';
}; };

View File

@ -116,16 +116,14 @@ namespace
reading_dependents = false; reading_dependents = false;
continue; continue;
} }
else if (line == "DEPENDENTS") if (line == "DEPENDENTS")
{ {
reading_dependents = true; reading_dependents = true;
reading_dependencies = false; reading_dependencies = false;
continue; continue;
} }
else if (line.empty()) if (line.empty())
{
continue; continue;
}
size_t separator1 = line.find('\t'); size_t separator1 = line.find('\t');
size_t separator2 = line.find('\t', separator1 + 1); size_t separator2 = line.find('\t', separator1 + 1);

View File

@ -134,7 +134,7 @@ public:
"' registered for user-defined settings", "' registered for user-defined settings",
String{setting_name}, boost::algorithm::join(registered_prefixes, "' or '")); String{setting_name}, boost::algorithm::join(registered_prefixes, "' or '"));
} }
else
throw Exception(ErrorCodes::UNKNOWN_SETTING, "Unknown setting '{}'", String{setting_name}); throw Exception(ErrorCodes::UNKNOWN_SETTING, "Unknown setting '{}'", String{setting_name});
} }
@ -830,7 +830,6 @@ std::shared_ptr<const EnabledQuota> AccessControl::getAuthenticationQuota(
quota_key, quota_key,
throw_if_client_key_empty); throw_if_client_key_empty);
} }
else
return nullptr; return nullptr;
} }

View File

@ -1483,16 +1483,16 @@ bool AccessRights::isGrantedImplHelper(const AccessRightsElement & element) cons
{ {
if (element.anyParameter()) if (element.anyParameter())
return isGrantedImpl<grant_option, wildcard>(element.access_flags); return isGrantedImpl<grant_option, wildcard>(element.access_flags);
else
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.parameter); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.parameter);
} }
else if (element.anyDatabase()) if (element.anyDatabase())
return isGrantedImpl<grant_option, wildcard>(element.access_flags); return isGrantedImpl<grant_option, wildcard>(element.access_flags);
else if (element.anyTable()) if (element.anyTable())
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database);
else if (element.anyColumn()) if (element.anyColumn())
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table);
else
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table, element.columns); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table, element.columns);
} }
@ -1503,17 +1503,15 @@ bool AccessRights::isGrantedImpl(const AccessRightsElement & element) const
{ {
if (element.grant_option) if (element.grant_option)
return isGrantedImplHelper<true, true>(element); return isGrantedImplHelper<true, true>(element);
else
return isGrantedImplHelper<grant_option, true>(element); return isGrantedImplHelper<grant_option, true>(element);
} }
else
{
if (element.grant_option) if (element.grant_option)
return isGrantedImplHelper<true, wildcard>(element); return isGrantedImplHelper<true, wildcard>(element);
else
return isGrantedImplHelper<grant_option, wildcard>(element); return isGrantedImplHelper<grant_option, wildcard>(element);
} }
}
template <bool grant_option, bool wildcard> template <bool grant_option, bool wildcard>
bool AccessRights::isGrantedImpl(const AccessRightsElements & elements) const bool AccessRights::isGrantedImpl(const AccessRightsElements & elements) const

View File

@ -501,10 +501,9 @@ AuthenticationData AuthenticationData::fromAST(const ASTAuthenticationData & que
auth_data.setPasswordHashBinary(AuthenticationData::Util::stringToDigest(value)); auth_data.setPasswordHashBinary(AuthenticationData::Util::stringToDigest(value));
return auth_data; return auth_data;
} }
else
{
auth_data.setPasswordHashHex(value); auth_data.setPasswordHashHex(value);
}
if (query.type == AuthenticationType::SHA256_PASSWORD && args_size == 2) if (query.type == AuthenticationType::SHA256_PASSWORD && args_size == 2)
{ {

View File

@ -247,7 +247,6 @@ namespace
const auto & unused_node = *(owned_nodes.begin()->second); const auto & unused_node = *(owned_nodes.begin()->second);
if (unused_node.node_type == UNKNOWN) if (unused_node.node_type == UNKNOWN)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Parent group '{}' not found", unused_node.keyword); throw Exception(ErrorCodes::LOGICAL_ERROR, "Parent group '{}' not found", unused_node.keyword);
else
throw Exception(ErrorCodes::LOGICAL_ERROR, "Access type '{}' should have parent group", unused_node.keyword); throw Exception(ErrorCodes::LOGICAL_ERROR, "Access type '{}' should have parent group", unused_node.keyword);
} }
} }

View File

@ -61,7 +61,7 @@ namespace
{ {
if (addr.family() == IPAddress::Family::IPv4 && addr_v6 == toIPv6(addr)) if (addr.family() == IPAddress::Family::IPv4 && addr_v6 == toIPv6(addr))
return true; return true;
else if (addr.family() == IPAddress::Family::IPv6 && addr_v6 == addr) if (addr.family() == IPAddress::Family::IPv6 && addr_v6 == addr)
return true; return true;
} }
@ -267,9 +267,8 @@ String AllowedClientHosts::IPSubnet::toString() const
unsigned int prefix_length = mask.prefixLength(); unsigned int prefix_length = mask.prefixLength();
if (isMaskAllBitsOne()) if (isMaskAllBitsOne())
return prefix.toString(); return prefix.toString();
else if (IPAddress{prefix_length, mask.family()} == mask) if (IPAddress{prefix_length, mask.family()} == mask)
return fs::path(prefix.toString()) / std::to_string(prefix_length); return fs::path(prefix.toString()) / std::to_string(prefix_length);
else
return fs::path(prefix.toString()) / mask.toString(); return fs::path(prefix.toString()) / mask.toString();
} }
@ -575,11 +574,10 @@ bool AllowedClientHosts::contains(const IPAddress & client_address) const
parseLikePattern(pattern, subnet, name, name_regexp); parseLikePattern(pattern, subnet, name, name_regexp);
if (subnet) if (subnet)
return check_subnet(*subnet); return check_subnet(*subnet);
else if (name) if (name)
return check_name(*name); return check_name(*name);
else if (name_regexp) if (name_regexp)
return check_name_regexp(*name_regexp); return check_name_regexp(*name_regexp);
else
return false; return false;
}; };

View File

@ -28,7 +28,6 @@ String QuotaTypeInfo::valueToString(QuotaValue value) const
{ {
if (!(value % output_denominator)) if (!(value % output_denominator))
return std::to_string(value / output_denominator); return std::to_string(value / output_denominator);
else
return toString(static_cast<double>(value) / output_denominator); return toString(static_cast<double>(value) / output_denominator);
} }
@ -36,7 +35,6 @@ QuotaValue QuotaTypeInfo::stringToValue(const String & str) const
{ {
if (output_denominator == 1) if (output_denominator == 1)
return static_cast<QuotaValue>(parse<UInt64>(str)); return static_cast<QuotaValue>(parse<UInt64>(str));
else
return static_cast<QuotaValue>(parse<Float64>(str) * output_denominator); return static_cast<QuotaValue>(parse<Float64>(str) * output_denominator);
} }

View File

@ -728,7 +728,6 @@ bool ContextAccess::checkAccessImplHelper(const ContextPtr & context, AccessFlag
"For queries over HTTP, method GET implies readonly. " "For queries over HTTP, method GET implies readonly. "
"You should use method POST for modifying queries"); "You should use method POST for modifying queries");
} }
else
return access_denied(ErrorCodes::READONLY, "{}: Cannot execute query in readonly mode"); return access_denied(ErrorCodes::READONLY, "{}: Cannot execute query in readonly mode");
} }
} }
@ -770,16 +769,16 @@ bool ContextAccess::checkAccessImplHelper(const ContextPtr & context, const Acce
{ {
if (element.anyParameter()) if (element.anyParameter())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags);
else
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.parameter); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.parameter);
} }
else if (element.anyDatabase()) if (element.anyDatabase())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags);
else if (element.anyTable()) if (element.anyTable())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database);
else if (element.anyColumn()) if (element.anyColumn())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table);
else
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table, element.columns); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table, element.columns);
} }
@ -790,17 +789,15 @@ bool ContextAccess::checkAccessImpl(const ContextPtr & context, const AccessRigh
{ {
if (element.grant_option) if (element.grant_option)
return checkAccessImplHelper<throw_if_denied, true, true>(context, element); return checkAccessImplHelper<throw_if_denied, true, true>(context, element);
else
return checkAccessImplHelper<throw_if_denied, grant_option, true>(context, element); return checkAccessImplHelper<throw_if_denied, grant_option, true>(context, element);
} }
else
{
if (element.grant_option) if (element.grant_option)
return checkAccessImplHelper<throw_if_denied, true, wildcard>(context, element); return checkAccessImplHelper<throw_if_denied, true, wildcard>(context, element);
else
return checkAccessImplHelper<throw_if_denied, grant_option, wildcard>(context, element); return checkAccessImplHelper<throw_if_denied, grant_option, wildcard>(context, element);
} }
}
template <bool throw_if_denied, bool grant_option, bool wildcard> template <bool throw_if_denied, bool grant_option, bool wildcard>
bool ContextAccess::checkAccessImpl(const ContextPtr & context, const AccessRightsElements & elements) const bool ContextAccess::checkAccessImpl(const ContextPtr & context, const AccessRightsElements & elements) const

View File

@ -89,9 +89,8 @@ bool operator ==(const ContextAccessParams & left, const ContextAccessParams & r
{ {
if (!x) if (!x)
return !y; return !y;
else if (!y) if (!y)
return false; return false;
else
return *x == *y; return *x == *y;
} }
else else
@ -132,22 +131,20 @@ bool operator <(const ContextAccessParams & left, const ContextAccessParams & ri
{ {
if (!x) if (!x)
return y ? -1 : 0; return y ? -1 : 0;
else if (!y) if (!y)
return 1; return 1;
else if (*x == *y) if (*x == *y)
return 0; return 0;
else if (*x < *y) if (*x < *y)
return -1; return -1;
else
return 1; return 1;
} }
else else
{ {
if (x == y) if (x == y)
return 0; return 0;
else if (x < y) if (x < y)
return -1; return -1;
else
return 1; return 1;
} }
}; };

View File

@ -166,7 +166,6 @@ void KerberosInit::init(const String & keytab_file, const String & principal, co
ret = krb5_get_init_creds_keytab(k5.ctx, &my_creds, k5.me, keytab, 0, nullptr, options); ret = krb5_get_init_creds_keytab(k5.ctx, &my_creds, k5.me, keytab, 0, nullptr, options);
if (ret) if (ret)
throw Exception(ErrorCodes::KERBEROS_ERROR, "Error in getting initial credentials: {}", fmtError(ret)); throw Exception(ErrorCodes::KERBEROS_ERROR, "Error in getting initial credentials: {}", fmtError(ret));
else
LOG_TRACE(log, "Got initial credentials"); LOG_TRACE(log, "Got initial credentials");
} }
else else

View File

@ -330,10 +330,7 @@ std::set<String> LDAPAccessStorage::mapExternalRolesNoLock(const LDAPClient::Sea
for (const auto & external_role : external_role_set) for (const auto & external_role : external_role_set)
{ {
if ( if (prefix.size() < external_role.size() && external_role.starts_with(prefix))
prefix.size() < external_role.size() &&
external_role.compare(0, prefix.size(), prefix) == 0
)
{ {
role_names.emplace(external_role, prefix.size()); role_names.emplace(external_role, prefix.size());
} }

View File

@ -62,7 +62,6 @@ String QuotaCache::QuotaInfo::calculateKey(const EnabledQuota & enabled, bool th
"Quota {} (for user {}) requires a client supplied key.", "Quota {} (for user {}) requires a client supplied key.",
quota->getName(), quota->getName(),
params.user_name); params.user_name);
else
return ""; // Authentication quota has no client key at time of authentication. return ""; // Authentication quota has no client key at time of authentication.
} }
case QuotaKeyType::CLIENT_KEY_OR_USER_NAME: case QuotaKeyType::CLIENT_KEY_OR_USER_NAME:

View File

@ -80,15 +80,13 @@ void RolesOrUsersSet::init(const ASTRolesOrUsersSet & ast, const AccessControl *
return *id; return *id;
return access_control->getID<Role>(name); return access_control->getID<Role>(name);
} }
else if (ast.allow_users) if (ast.allow_users)
{ {
return access_control->getID<User>(name); return access_control->getID<User>(name);
} }
else
{
assert(ast.allow_roles); assert(ast.allow_roles);
return access_control->getID<Role>(name); return access_control->getID<Role>(name);
}
}; };
if (!ast.names.empty() && !all) if (!ast.names.empty() && !all)

View File

@ -28,7 +28,7 @@ SettingsAuthResponseParser::parse(const Poco::Net::HTTPResponse & response, std:
try try
{ {
Poco::Dynamic::Var json = parser.parse(*body_stream); Poco::Dynamic::Var json = parser.parse(*body_stream);
Poco::JSON::Object::Ptr obj = json.extract<Poco::JSON::Object::Ptr>(); const Poco::JSON::Object::Ptr & obj = json.extract<Poco::JSON::Object::Ptr>();
Poco::JSON::Object::Ptr settings_obj = obj->getObject(settings_key); Poco::JSON::Object::Ptr settings_obj = obj->getObject(settings_key);
if (settings_obj) if (settings_obj)

View File

@ -54,7 +54,6 @@ SettingSourceRestrictions getSettingSourceRestrictions(std::string_view name)
auto settingConstraintIter = SETTINGS_SOURCE_RESTRICTIONS.find(name); auto settingConstraintIter = SETTINGS_SOURCE_RESTRICTIONS.find(name);
if (settingConstraintIter != SETTINGS_SOURCE_RESTRICTIONS.end()) if (settingConstraintIter != SETTINGS_SOURCE_RESTRICTIONS.end())
return settingConstraintIter->second; return settingConstraintIter->second;
else
return SettingSourceRestrictions(); // allows everything return SettingSourceRestrictions(); // allows everything
} }
@ -310,7 +309,6 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
{ {
if (reaction == THROW_ON_VIOLATION) if (reaction == THROW_ON_VIOLATION)
throw Exception(explain, code); throw Exception(explain, code);
else
return false; return false;
} }
@ -335,7 +333,6 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
{ {
if (reaction == THROW_ON_VIOLATION) if (reaction == THROW_ON_VIOLATION)
throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} should not be changed", setting_name); throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} should not be changed", setting_name);
else
return false; return false;
} }
@ -351,7 +348,6 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
max_value, max_value,
min_value, min_value,
setting_name); setting_name);
else
return false; return false;
} }
@ -362,7 +358,6 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be less than {}", throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be less than {}",
setting_name, applyVisitor(FieldVisitorToString(), min_value)); setting_name, applyVisitor(FieldVisitorToString(), min_value));
} }
else
change.value = min_value; change.value = min_value;
} }
@ -373,7 +368,6 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be greater than {}", throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be greater than {}",
setting_name, applyVisitor(FieldVisitorToString(), max_value)); setting_name, applyVisitor(FieldVisitorToString(), max_value));
} }
else
change.value = max_value; change.value = max_value;
} }
@ -381,7 +375,6 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
{ {
if (reaction == THROW_ON_VIOLATION) if (reaction == THROW_ON_VIOLATION)
throw Exception(ErrorCodes::READONLY, "Setting {} is not allowed to be set by {}", setting_name, toString(source)); throw Exception(ErrorCodes::READONLY, "Setting {} is not allowed to be set by {}", setting_name, toString(source));
else
return false; return false;
} }

View File

@ -649,7 +649,6 @@ namespace
{ {
if (users_without_row_policies_can_read_rows) if (users_without_row_policies_can_read_rows)
continue; continue;
else
filter = "1"; filter = "1";
} }

View File

@ -157,13 +157,13 @@ public:
d.status = static_cast<Data::Status>(k); d.status = static_cast<Data::Status>(k);
if (d.status == Data::Status::NotSet) if (d.status == Data::Status::NotSet)
return; return;
else if (d.status == Data::Status::SetNull) if (d.status == Data::Status::SetNull)
{ {
if (!returns_nullable_type) if (!returns_nullable_type)
throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect type (NULL) in non-nullable {}State", getName()); throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect type (NULL) in non-nullable {}State", getName());
return; return;
} }
else if (d.status == Data::Status::SetOther) if (d.status == Data::Status::SetOther)
{ {
serialization->deserializeBinary(d.value, buf, {}); serialization->deserializeBinary(d.value, buf, {});
return; return;

View File

@ -148,9 +148,8 @@ AggregateFunctionPtr createAggregateFunctionDeltaSum(
if (isInteger(data_type) || isFloat(data_type)) if (isInteger(data_type) || isFloat(data_type))
return AggregateFunctionPtr(createWithNumericType<AggregationFunctionDeltaSum>( return AggregateFunctionPtr(createWithNumericType<AggregationFunctionDeltaSum>(
*data_type, arguments, params)); *data_type, arguments, params));
else throw Exception(
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for aggregate function {}", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for aggregate function {}", arguments[0]->getName(), name);
arguments[0]->getName(), name);
} }
} }

View File

@ -137,13 +137,12 @@ AggregateFunctionFactory::getAssociatedFunctionByNullsAction(const String & name
{ {
if (action == NullsAction::RESPECT_NULLS) if (action == NullsAction::RESPECT_NULLS)
{ {
if (auto it = respect_nulls.find(name); it == respect_nulls.end()) auto it = respect_nulls.find(name);
if (it == respect_nulls.end())
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Function {} does not support RESPECT NULLS", name); throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Function {} does not support RESPECT NULLS", name);
else if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end()) if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end())
return {associated_it->second}; return {associated_it->second};
else throw Exception(ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} RESPECT NULLS')", it->second, name);
throw Exception(
ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} RESPECT NULLS')", it->second, name);
} }
if (action == NullsAction::IGNORE_NULLS) if (action == NullsAction::IGNORE_NULLS)
@ -152,7 +151,6 @@ AggregateFunctionFactory::getAssociatedFunctionByNullsAction(const String & name
{ {
if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end()) if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end())
return {associated_it->second}; return {associated_it->second};
else
throw Exception( throw Exception(
ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} IGNORE NULLS')", it->second, name); ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} IGNORE NULLS')", it->second, name);
} }
@ -263,7 +261,6 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl(
if (!hints.empty()) if (!hints.empty())
throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION, throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION,
"Unknown aggregate function {}{}. Maybe you meant: {}", name, extra_info, toString(hints)); "Unknown aggregate function {}{}. Maybe you meant: {}", name, extra_info, toString(hints));
else
throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION, "Unknown aggregate function {}{}", name, extra_info); throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION, "Unknown aggregate function {}{}", name, extra_info);
} }

View File

@ -328,8 +328,7 @@ struct AggregateFunctionFlameGraphData
list = list->next; list = list->next;
return entry; return entry;
} }
else
{
Entry * parent = list; Entry * parent = list;
while (parent->next && parent->next->size != size) while (parent->next && parent->next->size != size)
parent = parent->next; parent = parent->next;
@ -343,7 +342,6 @@ struct AggregateFunctionFlameGraphData
return nullptr; return nullptr;
} }
}
void add(UInt64 ptr, Int64 size, const UInt64 * stack, size_t stack_size, Arena * arena) void add(UInt64 ptr, Int64 size, const UInt64 * stack, size_t stack_size, Arena * arena)
{ {

View File

@ -90,7 +90,6 @@ struct GroupArraySamplerData
/// With a large number of values, we will generate random numbers several times slower. /// With a large number of values, we will generate random numbers several times slower.
if (lim <= static_cast<UInt64>(pcg32_fast::max())) if (lim <= static_cast<UInt64>(pcg32_fast::max()))
return rng() % lim; return rng() % lim;
else
return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32::max()) + 1ULL) + static_cast<UInt64>(rng())) % lim; return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32::max()) + 1ULL) + static_cast<UInt64>(rng())) % lim;
} }
@ -797,8 +796,8 @@ AggregateFunctionPtr createAggregateFunctionGroupArray(
throw Exception(ErrorCodes::BAD_ARGUMENTS, "groupArrayLast make sense only with max_elems (groupArrayLast(max_elems)())"); throw Exception(ErrorCodes::BAD_ARGUMENTS, "groupArrayLast make sense only with max_elems (groupArrayLast(max_elems)())");
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ false, Tlast, /* Tsampler= */ Sampler::NONE>>(argument_types[0], parameters, max_elems, std::nullopt); return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ false, Tlast, /* Tsampler= */ Sampler::NONE>>(argument_types[0], parameters, max_elems, std::nullopt);
} }
else return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ true, Tlast, /* Tsampler= */ Sampler::NONE>>(
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ true, Tlast, /* Tsampler= */ Sampler::NONE>>(argument_types[0], parameters, max_elems, std::nullopt); argument_types[0], parameters, max_elems, std::nullopt);
} }
AggregateFunctionPtr createAggregateFunctionGroupArraySample( AggregateFunctionPtr createAggregateFunctionGroupArraySample(

View File

@ -381,24 +381,23 @@ IAggregateFunction * createWithExtraTypes(const DataTypePtr & argument_type, con
{ {
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupArrayIntersectDate(argument_type, parameters); if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupArrayIntersectDate(argument_type, parameters);
else if (which.idx == TypeIndex::DateTime) return new AggregateFunctionGroupArrayIntersectDateTime(argument_type, parameters); if (which.idx == TypeIndex::DateTime)
else if (which.idx == TypeIndex::Date32) return new AggregateFunctionGroupArrayIntersectDate32(argument_type, parameters); return new AggregateFunctionGroupArrayIntersectDateTime(argument_type, parameters);
else if (which.idx == TypeIndex::DateTime64) if (which.idx == TypeIndex::Date32)
return new AggregateFunctionGroupArrayIntersectDate32(argument_type, parameters);
if (which.idx == TypeIndex::DateTime64)
{ {
const auto * datetime64_type = dynamic_cast<const DataTypeDateTime64 *>(argument_type.get()); const auto * datetime64_type = dynamic_cast<const DataTypeDateTime64 *>(argument_type.get());
const auto return_type = std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime64>(datetime64_type->getScale())); const auto return_type = std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime64>(datetime64_type->getScale()));
return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters, return_type); return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters, return_type);
} }
else
{
/// Check that we can use plain version of AggregateFunctionGroupArrayIntersectGeneric /// Check that we can use plain version of AggregateFunctionGroupArrayIntersectGeneric
if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion()) if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters); return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters);
else
return new AggregateFunctionGroupArrayIntersectGeneric<false>(argument_type, parameters); return new AggregateFunctionGroupArrayIntersectGeneric<false>(argument_type, parameters);
} }
}
inline AggregateFunctionPtr createAggregateFunctionGroupArrayIntersectImpl(const std::string & name, const DataTypePtr & argument_type, const Array & parameters) inline AggregateFunctionPtr createAggregateFunctionGroupArrayIntersectImpl(const std::string & name, const DataTypePtr & argument_type, const Array & parameters)
{ {

View File

@ -65,7 +65,6 @@ struct MovingSumData : public MovingData<T>
{ {
if (idx < window_size) if (idx < window_size)
return this->value[idx]; return this->value[idx];
else
return this->value[idx] - this->value[idx - window_size]; return this->value[idx] - this->value[idx - window_size];
} }
}; };
@ -79,7 +78,6 @@ struct MovingAvgData : public MovingData<T>
{ {
if (idx < window_size) if (idx < window_size)
return this->value[idx] / T(window_size); return this->value[idx] / T(window_size);
else
return (this->value[idx] - this->value[idx - window_size]) / T(window_size); return (this->value[idx] - this->value[idx - window_size]) / T(window_size);
} }
}; };
@ -285,17 +283,13 @@ AggregateFunctionPtr createAggregateFunctionMoving(
{ {
if (isDecimal(argument_type)) if (isDecimal(argument_type))
return createAggregateFunctionMovingImpl<Function, std::false_type, std::true_type>(name, argument_type); return createAggregateFunctionMovingImpl<Function, std::false_type, std::true_type>(name, argument_type);
else
return createAggregateFunctionMovingImpl<Function, std::false_type, std::false_type>(name, argument_type); return createAggregateFunctionMovingImpl<Function, std::false_type, std::false_type>(name, argument_type);
} }
else
{
if (isDecimal(argument_type)) if (isDecimal(argument_type))
return createAggregateFunctionMovingImpl<Function, std::true_type, std::true_type>(name, argument_type, max_elems); return createAggregateFunctionMovingImpl<Function, std::true_type, std::true_type>(name, argument_type, max_elems);
else
return createAggregateFunctionMovingImpl<Function, std::true_type, std::false_type>(name, argument_type, max_elems); return createAggregateFunctionMovingImpl<Function, std::true_type, std::false_type>(name, argument_type, max_elems);
} }
}
} }

View File

@ -391,21 +391,20 @@ AggregateFunctionPtr createAggregateFunctionGroupArray(
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should have limit argument", name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should have limit argument", name);
} }
else if (parameters.size() == 1) if (parameters.size() == 1)
{ {
auto type = parameters[0].getType(); auto type = parameters[0].getType();
if (type != Field::Types::Int64 && type != Field::Types::UInt64) if (type != Field::Types::Int64 && type != Field::Types::UInt64)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name);
if ((type == Field::Types::Int64 && parameters[0].safeGet<Int64>() < 0) || if ((type == Field::Types::Int64 && parameters[0].safeGet<Int64>() < 0)
(type == Field::Types::UInt64 && parameters[0].safeGet<UInt64>() == 0)) || (type == Field::Types::UInt64 && parameters[0].safeGet<UInt64>() == 0))
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name);
max_elems = parameters[0].safeGet<UInt64>(); max_elems = parameters[0].safeGet<UInt64>();
} }
else else
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {} does not support this number of arguments", name);
"Function {} does not support this number of arguments", name);
if (max_elems > group_array_sorted_sort_strategy_max_elements_threshold) if (max_elems > group_array_sorted_sort_strategy_max_elements_threshold)
return createAggregateFunctionGroupArraySortedImpl<GroupArraySortedSort>(argument_types[0], parameters, max_elems); return createAggregateFunctionGroupArraySortedImpl<GroupArraySortedSort>(argument_types[0], parameters, max_elems);

View File

@ -133,7 +133,6 @@ public:
{ {
if (revision >= STATE_VERSION_1_MIN_REVISION) if (revision >= STATE_VERSION_1_MIN_REVISION)
return 1; return 1;
else
return 0; return 0;
} }

View File

@ -88,7 +88,6 @@ public:
{ {
if (isSmall()) if (isSmall())
return small.size(); return small.size();
else
return roaring_bitmap->cardinality(); return roaring_bitmap->cardinality();
} }
@ -454,7 +453,6 @@ public:
if (isSmall()) if (isSmall())
return small.find(static_cast<T>(x)) != small.end(); return small.find(static_cast<T>(x)) != small.end();
else
return roaring_bitmap->contains(static_cast<Value>(x)); return roaring_bitmap->contains(static_cast<Value>(x));
} }
@ -554,8 +552,7 @@ public:
r1.add(elem); r1.add(elem);
return answer.size(); return answer.size();
} }
else
{
UInt64 count = 0; UInt64 count = 0;
for (auto it = roaring_bitmap->begin(); it != roaring_bitmap->end(); ++it) for (auto it = roaring_bitmap->begin(); it != roaring_bitmap->end(); ++it)
{ {
@ -572,7 +569,6 @@ public:
} }
return count; return count;
} }
}
UInt64 rb_offset_limit(UInt64 offset, UInt64 limit, RoaringBitmapWithSmallSet & r1) const /// NOLINT UInt64 rb_offset_limit(UInt64 offset, UInt64 limit, RoaringBitmapWithSmallSet & r1) const /// NOLINT
{ {
@ -591,8 +587,7 @@ public:
r1.add(it->getValue()); r1.add(it->getValue());
return count; return count;
} }
else
{
UInt64 count = 0; UInt64 count = 0;
UInt64 offset_count = 0; UInt64 offset_count = 0;
auto it = roaring_bitmap->begin(); auto it = roaring_bitmap->begin();
@ -603,7 +598,6 @@ public:
r1.add(*it); r1.add(*it);
return count; return count;
} }
}
UInt64 rb_min() const /// NOLINT UInt64 rb_min() const /// NOLINT
{ {
@ -620,7 +614,6 @@ public:
} }
return min_val; return min_val;
} }
else
return roaring_bitmap->minimum(); return roaring_bitmap->minimum();
} }
@ -639,7 +632,6 @@ public:
} }
return max_val; return max_val;
} }
else
return roaring_bitmap->maximum(); return roaring_bitmap->maximum();
} }

View File

@ -275,7 +275,6 @@ AggregateFunctionPtr createAggregateFunctionGroupConcat(
if (has_limit) if (has_limit)
return std::make_shared<GroupConcatImpl</* has_limit= */ true>>(argument_types[0], parameters, limit, delimiter); return std::make_shared<GroupConcatImpl</* has_limit= */ true>>(argument_types[0], parameters, limit, delimiter);
else
return std::make_shared<GroupConcatImpl</* has_limit= */ false>>(argument_types[0], parameters, limit, delimiter); return std::make_shared<GroupConcatImpl</* has_limit= */ false>>(argument_types[0], parameters, limit, delimiter);
} }

View File

@ -276,17 +276,16 @@ IAggregateFunction * createWithExtraTypes(const DataTypePtr & argument_type, TAr
{ {
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupUniqArrayDate<HasLimit>(argument_type, args...); if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupUniqArrayDate<HasLimit>(argument_type, args...);
else if (which.idx == TypeIndex::DateTime) return new AggregateFunctionGroupUniqArrayDateTime<HasLimit>(argument_type, args...); if (which.idx == TypeIndex::DateTime)
else if (which.idx == TypeIndex::IPv4) return new AggregateFunctionGroupUniqArrayIPv4<HasLimit>(argument_type, args...); return new AggregateFunctionGroupUniqArrayDateTime<HasLimit>(argument_type, args...);
else if (which.idx == TypeIndex::IPv4)
{ return new AggregateFunctionGroupUniqArrayIPv4<HasLimit>(argument_type, args...);
/// Check that we can use plain version of AggregateFunctionGroupUniqArrayGeneric /// Check that we can use plain version of AggregateFunctionGroupUniqArrayGeneric
if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion()) if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
return new AggregateFunctionGroupUniqArrayGeneric<true, HasLimit>(argument_type, args...); return new AggregateFunctionGroupUniqArrayGeneric<true, HasLimit>(argument_type, args...);
else
return new AggregateFunctionGroupUniqArrayGeneric<false, HasLimit>(argument_type, args...); return new AggregateFunctionGroupUniqArrayGeneric<false, HasLimit>(argument_type, args...);
} }
}
template <typename HasLimit, typename ... TArgs> template <typename HasLimit, typename ... TArgs>
inline AggregateFunctionPtr createAggregateFunctionGroupUniqArrayImpl(const std::string & name, const DataTypePtr & argument_type, TArgs ... args) inline AggregateFunctionPtr createAggregateFunctionGroupUniqArrayImpl(const std::string & name, const DataTypePtr & argument_type, TArgs ... args)
@ -336,7 +335,6 @@ AggregateFunctionPtr createAggregateFunctionGroupUniqArray(
if (!limit_size) if (!limit_size)
return createAggregateFunctionGroupUniqArrayImpl<std::false_type>(name, argument_types[0], parameters); return createAggregateFunctionGroupUniqArrayImpl<std::false_type>(name, argument_types[0], parameters);
else
return createAggregateFunctionGroupUniqArrayImpl<std::true_type>(name, argument_types[0], parameters, max_elems); return createAggregateFunctionGroupUniqArrayImpl<std::true_type>(name, argument_types[0], parameters, max_elems);
} }

View File

@ -87,7 +87,6 @@ public:
{ {
if (kind_ == AggregateFunctionIntersectionsKind::Count) if (kind_ == AggregateFunctionIntersectionsKind::Count)
return std::make_shared<DataTypeUInt64>(); return std::make_shared<DataTypeUInt64>();
else
return std::make_shared<DataTypeNumber<PointType>>(); return std::make_shared<DataTypeNumber<PointType>>();
} }

View File

@ -138,7 +138,9 @@ public:
{ {
if (other.count == 0) if (other.count == 0)
return; return;
else if (count == 0)
/// NOLINTBEGIN(readability-else-after-return)
if (count == 0)
{ {
compress_threshold = other.compress_threshold; compress_threshold = other.compress_threshold;
relative_error = other.relative_error; relative_error = other.relative_error;
@ -237,6 +239,7 @@ public:
doCompress(2 * merged_relative_error * merged_count); doCompress(2 * merged_relative_error * merged_count);
compressed = true; compressed = true;
} }
/// NOLINTEND(readability-else-after-return)
} }
void write(WriteBuffer & buf) const void write(WriteBuffer & buf) const
@ -292,13 +295,11 @@ private:
Int64 max_rank = min_rank + curr_sample.delta; Int64 max_rank = min_rank + curr_sample.delta;
if (max_rank - target_error <= rank && rank <= min_rank + target_error) if (max_rank - target_error <= rank && rank <= min_rank + target_error)
return {i, min_rank, curr_sample.value}; return {i, min_rank, curr_sample.value};
else
{
++i; ++i;
curr_sample = sampled[i]; curr_sample = sampled[i];
min_rank += curr_sample.g; min_rank += curr_sample.g;
} }
}
return {sampled.size() - 1, 0, sampled.back().value}; return {sampled.size() - 1, 0, sampled.back().value};
} }

View File

@ -747,7 +747,7 @@ AggregateFunctionPtr createAggregateFunctionSequenceBase(
WhichDataType which(argument_types.front().get()); WhichDataType which(argument_types.front().get());
if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunction<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(argument_types, params, pattern); return std::make_shared<AggregateFunction<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(argument_types, params, pattern);
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunction<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(argument_types, params, pattern); return std::make_shared<AggregateFunction<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(argument_types, params, pattern);
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,

View File

@ -124,7 +124,6 @@ private:
{ {
if (count < 2) if (count < 2)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else
return m2 / (count - 1); return m2 / (count - 1);
} }
@ -137,9 +136,8 @@ private:
{ {
if (count == 0) if (count == 0)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else if (count == 1) if (count == 1)
return 0.0; return 0.0;
else
return m2 / count; return m2 / count;
} }
@ -363,7 +361,6 @@ private:
{ {
if (count < 2) if (count < 2)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else
return co_moment / (count - 1); return co_moment / (count - 1);
} }
@ -371,9 +368,8 @@ private:
{ {
if (count == 0) if (count == 0)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else if (count == 1) if (count == 1)
return 0.0; return 0.0;
else
return co_moment / count; return co_moment / count;
} }
@ -381,7 +377,6 @@ private:
{ {
if (count < 2) if (count < 2)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else
return co_moment / sqrt(left_m2 * right_m2); return co_moment / sqrt(left_m2 * right_m2);
} }

View File

@ -112,7 +112,6 @@ public:
{ {
if (revision >= STATE_VERSION_1_MIN_REVISION) if (revision >= STATE_VERSION_1_MIN_REVISION)
return 1; return 1;
else
return 0; return 0;
} }
@ -764,7 +763,6 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMap<false, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMap<false, true>>(keys_type, values_types, arguments, params);
else
return std::make_shared<AggregateFunctionSumMap<false, false>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMap<false, false>>(keys_type, values_types, arguments, params);
}); });
@ -773,7 +771,6 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionMinMap<true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionMinMap<true>>(keys_type, values_types, arguments, params);
else
return std::make_shared<AggregateFunctionMinMap<false>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionMinMap<false>>(keys_type, values_types, arguments, params);
}); });
@ -782,7 +779,6 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionMaxMap<true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionMaxMap<true>>(keys_type, values_types, arguments, params);
else
return std::make_shared<AggregateFunctionMaxMap<false>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionMaxMap<false>>(keys_type, values_types, arguments, params);
}); });
@ -793,7 +789,6 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMap<true, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMap<true, true>>(keys_type, values_types, arguments, params);
else
return std::make_shared<AggregateFunctionSumMap<true, false>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMap<true, false>>(keys_type, values_types, arguments, params);
}); });
@ -802,7 +797,6 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMapFiltered<false, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMapFiltered<false, true>>(keys_type, values_types, arguments, params);
else
return std::make_shared<AggregateFunctionSumMapFiltered<false, false>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMapFiltered<false, false>>(keys_type, values_types, arguments, params);
}); });
@ -811,7 +805,6 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMapFiltered<true, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMapFiltered<true, true>>(keys_type, values_types, arguments, params);
else
return std::make_shared<AggregateFunctionSumMapFiltered<true, false>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMapFiltered<true, false>>(keys_type, values_types, arguments, params);
}); });
} }

View File

@ -96,25 +96,18 @@ public:
std::move(names) std::move(names)
); );
} }
else
{ DataTypes types{
DataTypes types
{
std::make_shared<DataTypeNumber<Float64>>(), std::make_shared<DataTypeNumber<Float64>>(),
std::make_shared<DataTypeNumber<Float64>>(), std::make_shared<DataTypeNumber<Float64>>(),
}; };
Strings names Strings names{
{
"t_statistic", "t_statistic",
"p_value", "p_value",
}; };
return std::make_shared<DataTypeTuple>( return std::make_shared<DataTypeTuple>(std::move(types), std::move(names));
std::move(types),
std::move(names)
);
}
} }
bool allocatesMemoryInArena() const override { return false; } bool allocatesMemoryInArena() const override { return false; }

View File

@ -79,7 +79,6 @@ public:
{ {
if (is_approx_top_k) if (is_approx_top_k)
return is_weighted ? "approx_top_sum" : "approx_top_k"; return is_weighted ? "approx_top_sum" : "approx_top_k";
else
return is_weighted ? "topKWeighted" : "topK"; return is_weighted ? "topKWeighted" : "topK";
} }
@ -106,7 +105,6 @@ public:
std::move(names) std::move(names)
)); ));
} }
else
return std::make_shared<DataTypeArray>(argument_types_[0]); return std::make_shared<DataTypeArray>(argument_types_[0]);
} }
@ -226,7 +224,6 @@ public:
{ {
if (is_approx_top_k) if (is_approx_top_k)
return is_weighted ? "approx_top_sum" : "approx_top_k"; return is_weighted ? "approx_top_sum" : "approx_top_k";
else
return is_weighted ? "topKWeighted" : "topK"; return is_weighted ? "topKWeighted" : "topK";
} }
@ -253,10 +250,8 @@ public:
std::move(names) std::move(names)
)); ));
} else
{
return std::make_shared<DataTypeArray>(argument_types_[0]);
} }
return std::make_shared<DataTypeArray>(argument_types_[0]);
} }
bool allocatesMemoryInArena() const override bool allocatesMemoryInArena() const override
@ -440,8 +435,8 @@ IAggregateFunction * createWithExtraTypes(const DataTypes & argument_types, UInt
/// Check that we can use plain version of AggregateFunctionTopKGeneric /// Check that we can use plain version of AggregateFunctionTopKGeneric
if (argument_types[0]->isValueUnambiguouslyRepresentedInContiguousMemoryRegion()) if (argument_types[0]->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
return new AggregateFunctionTopKGeneric<true, is_weighted>(threshold, reserved, include_counts, is_approx_top_k, argument_types, params); return new AggregateFunctionTopKGeneric<true, is_weighted>(threshold, reserved, include_counts, is_approx_top_k, argument_types, params);
else return new AggregateFunctionTopKGeneric<false, is_weighted>(
return new AggregateFunctionTopKGeneric<false, is_weighted>(threshold, reserved, include_counts, is_approx_top_k, argument_types, params); threshold, reserved, include_counts, is_approx_top_k, argument_types, params);
} }

View File

@ -54,25 +54,24 @@ createAggregateFunctionUniq(const std::string & name, const DataTypes & argument
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionUniq<DataTypeDate::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeDate::FieldType, Data>>(argument_types);
else if (which.isDate32()) if (which.isDate32())
return std::make_shared<AggregateFunctionUniq<DataTypeDate32::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeDate32::FieldType, Data>>(argument_types);
else if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunctionUniq<DataTypeDateTime::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeDateTime::FieldType, Data>>(argument_types);
else if (which.isStringOrFixedString()) if (which.isStringOrFixedString())
return std::make_shared<AggregateFunctionUniq<String, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<String, Data>>(argument_types);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<AggregateFunctionUniq<DataTypeUUID::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeUUID::FieldType, Data>>(argument_types);
else if (which.isIPv4()) if (which.isIPv4())
return std::make_shared<AggregateFunctionUniq<DataTypeIPv4::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeIPv4::FieldType, Data>>(argument_types);
else if (which.isIPv6()) if (which.isIPv6())
return std::make_shared<AggregateFunctionUniq<DataTypeIPv6::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeIPv6::FieldType, Data>>(argument_types);
else if (which.isTuple()) if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true>>>(argument_types);
else
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true>>>(argument_types);
} }
} }
@ -80,7 +79,6 @@ createAggregateFunctionUniq(const std::string & name, const DataTypes & argument
/// "Variadic" method also works as a fallback generic case for single argument. /// "Variadic" method also works as a fallback generic case for single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false>>>(argument_types);
else
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false>>>(argument_types);
} }
@ -107,33 +105,45 @@ createAggregateFunctionUniq(const std::string & name, const DataTypes & argument
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionUniq<DataTypeDate::FieldType, Data<DataTypeDate::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isDate32()) AggregateFunctionUniq<DataTypeDate::FieldType, Data<DataTypeDate::FieldType, is_able_to_parallelize_merge>>>(
return std::make_shared<AggregateFunctionUniq<DataTypeDate32::FieldType, Data<DataTypeDate32::FieldType, is_able_to_parallelize_merge>>>(argument_types); argument_types);
else if (which.isDateTime()) if (which.isDate32())
return std::make_shared<AggregateFunctionUniq<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isStringOrFixedString()) AggregateFunctionUniq<DataTypeDate32::FieldType, Data<DataTypeDate32::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isDateTime())
return std::make_shared<
AggregateFunctionUniq<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isStringOrFixedString())
return std::make_shared<AggregateFunctionUniq<String, Data<String, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniq<String, Data<String, is_able_to_parallelize_merge>>>(argument_types);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<AggregateFunctionUniq<DataTypeUUID::FieldType, Data<DataTypeUUID::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isIPv4()) AggregateFunctionUniq<DataTypeUUID::FieldType, Data<DataTypeUUID::FieldType, is_able_to_parallelize_merge>>>(
return std::make_shared<AggregateFunctionUniq<DataTypeIPv4::FieldType, Data<DataTypeIPv4::FieldType, is_able_to_parallelize_merge>>>(argument_types); argument_types);
else if (which.isIPv6()) if (which.isIPv4())
return std::make_shared<AggregateFunctionUniq<DataTypeIPv6::FieldType, Data<DataTypeIPv6::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isTuple()) AggregateFunctionUniq<DataTypeIPv4::FieldType, Data<DataTypeIPv4::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isIPv6())
return std::make_shared<
AggregateFunctionUniq<DataTypeIPv6::FieldType, Data<DataTypeIPv6::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true, is_able_to_parallelize_merge>>>(
else argument_types);
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true, is_able_to_parallelize_merge>>>(
argument_types);
} }
} }
/// "Variadic" method also works as a fallback generic case for single argument. /// "Variadic" method also works as a fallback generic case for single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false, is_able_to_parallelize_merge>>>(argument_types);
else
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false, is_able_to_parallelize_merge>>>(argument_types);
} }
@ -155,9 +165,11 @@ void registerAggregateFunctionsUniq(AggregateFunctionFactory & factory)
if (settings && (*settings)[Setting::max_threads] > 1) if (settings && (*settings)[Setting::max_threads] > 1)
return createAggregateFunctionUniq< return createAggregateFunctionUniq<
true, AggregateFunctionUniqExactData, AggregateFunctionUniqExactDataForVariadic, true /* is_able_to_parallelize_merge */>(name, argument_types, params, settings); true, AggregateFunctionUniqExactData, AggregateFunctionUniqExactDataForVariadic, true /* is_able_to_parallelize_merge */>(name, argument_types, params, settings);
else
return createAggregateFunctionUniq< return createAggregateFunctionUniq<
true, AggregateFunctionUniqExactData, AggregateFunctionUniqExactDataForVariadic, false /* is_able_to_parallelize_merge */>(name, argument_types, params, settings); true,
AggregateFunctionUniqExactData,
AggregateFunctionUniqExactDataForVariadic,
false /* is_able_to_parallelize_merge */>(name, argument_types, params, settings);
}; };
factory.registerFunction("uniqExact", {assign_bool_param, properties}); factory.registerFunction("uniqExact", {assign_bool_param, properties});

View File

@ -235,33 +235,39 @@ AggregateFunctionPtr createAggregateFunctionWithK(const DataTypes & argument_typ
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate::FieldType>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate::FieldType>>(
else if (which.isDate32()) argument_types, params);
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate32::FieldType>>(argument_types, params); if (which.isDate32())
else if (which.isDateTime()) return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate32::FieldType>>(
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDateTime::FieldType>>(argument_types, params); argument_types, params);
else if (which.isStringOrFixedString()) if (which.isDateTime())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDateTime::FieldType>>(
argument_types, params);
if (which.isStringOrFixedString())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<String>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<String>>(argument_types, params);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeUUID::FieldType>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeUUID::FieldType>>(
else if (which.isIPv4()) argument_types, params);
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv4::FieldType>>(argument_types, params); if (which.isIPv4())
else if (which.isIPv6()) return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv4::FieldType>>(
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv6::FieldType>>(argument_types, params); argument_types, params);
else if (which.isTuple()) if (which.isIPv6())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv6::FieldType>>(
argument_types, params);
if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, true>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, true>>(
else argument_types, params);
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, true>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, true>>(
argument_types, params);
} }
} }
/// "Variadic" method also works as a fallback generic case for a single argument. /// "Variadic" method also works as a fallback generic case for a single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, false>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, false>>(argument_types, params);
else
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, false>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, false>>(argument_types, params);
} }
@ -270,7 +276,6 @@ AggregateFunctionPtr createAggregateFunctionWithHashType(bool use_64_bit_hash, c
{ {
if (use_64_bit_hash) if (use_64_bit_hash)
return createAggregateFunctionWithK<K, UInt64>(argument_types, params); return createAggregateFunctionWithK<K, UInt64>(argument_types, params);
else
return createAggregateFunctionWithK<K, UInt32>(argument_types, params); return createAggregateFunctionWithK<K, UInt32>(argument_types, params);
} }

View File

@ -324,21 +324,20 @@ AggregateFunctionPtr createAggregateFunctionUniqUpTo(const std::string & name, c
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate::FieldType>>(threshold, argument_types, params);
else if (which.isDate32()) if (which.isDate32())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate32::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate32::FieldType>>(threshold, argument_types, params);
else if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDateTime::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDateTime::FieldType>>(threshold, argument_types, params);
else if (which.isStringOrFixedString()) if (which.isStringOrFixedString())
return std::make_shared<AggregateFunctionUniqUpTo<String>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<String>>(threshold, argument_types, params);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeUUID::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeUUID::FieldType>>(threshold, argument_types, params);
else if (which.isTuple()) if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqUpToVariadic<true, true>>(argument_types, params, threshold); return std::make_shared<AggregateFunctionUniqUpToVariadic<true, true>>(argument_types, params, threshold);
else
return std::make_shared<AggregateFunctionUniqUpToVariadic<false, true>>(argument_types, params, threshold); return std::make_shared<AggregateFunctionUniqUpToVariadic<false, true>>(argument_types, params, threshold);
} }
} }
@ -346,7 +345,6 @@ AggregateFunctionPtr createAggregateFunctionUniqUpTo(const std::string & name, c
/// "Variadic" method also works as a fallback generic case for single argument. /// "Variadic" method also works as a fallback generic case for single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqUpToVariadic<true, false>>(argument_types, params, threshold); return std::make_shared<AggregateFunctionUniqUpToVariadic<true, false>>(argument_types, params, threshold);
else
return std::make_shared<AggregateFunctionUniqUpToVariadic<false, false>>(argument_types, params, threshold); return std::make_shared<AggregateFunctionUniqUpToVariadic<false, false>>(argument_types, params, threshold);
} }

View File

@ -180,10 +180,9 @@ private:
{ {
if (first_event) if (first_event)
break; break;
else
continue; continue;
} }
else if (event_idx == 0) if (event_idx == 0)
{ {
events_timestamp[0] = std::make_pair(timestamp, timestamp); events_timestamp[0] = std::make_pair(timestamp, timestamp);
first_event = true; first_event = true;
@ -326,10 +325,11 @@ createAggregateFunctionWindowFunnel(const std::string & name, const DataTypes &
WhichDataType which(arguments.front().get()); WhichDataType which(arguments.front().get());
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(arguments, params); return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(arguments, params);
else if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(arguments, params); return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(
arguments, params);
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of first argument of aggregate function {}, must " "Illegal type {} of first argument of aggregate function {}, must "

View File

@ -50,10 +50,8 @@ public:
return std::make_shared< return std::make_shared<
AggregateFunctionDistinct< AggregateFunctionDistinct<
AggregateFunctionDistinctSingleGenericData<true>>>(nested_function, arguments, params); AggregateFunctionDistinctSingleGenericData<true>>>(nested_function, arguments, params);
else return std::make_shared<AggregateFunctionDistinct<AggregateFunctionDistinctSingleGenericData<false>>>(
return std::make_shared< nested_function, arguments, params);
AggregateFunctionDistinct<
AggregateFunctionDistinctSingleGenericData<false>>>(nested_function, arguments, params);
} }
return std::make_shared<AggregateFunctionDistinct<AggregateFunctionDistinctMultipleGenericData>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionDistinct<AggregateFunctionDistinctMultipleGenericData>>(nested_function, arguments, params);

View File

@ -473,29 +473,21 @@ AggregateFunctionPtr AggregateFunctionIf::getOwnNullAdapter(
{ {
return std::make_shared<AggregateFunctionIfNullUnary<true, true>>(nested_function->getName(), nested_func, arguments, params); return std::make_shared<AggregateFunctionIfNullUnary<true, true>>(nested_function->getName(), nested_func, arguments, params);
} }
else
{
if (need_to_serialize_flag) if (need_to_serialize_flag)
return std::make_shared<AggregateFunctionIfNullUnary<false, true>>(nested_function->getName(), nested_func, arguments, params); return std::make_shared<AggregateFunctionIfNullUnary<false, true>>(nested_function->getName(), nested_func, arguments, params);
else
return std::make_shared<AggregateFunctionIfNullUnary<false, false>>(nested_function->getName(), nested_func, arguments, params); return std::make_shared<AggregateFunctionIfNullUnary<false, false>>(nested_function->getName(), nested_func, arguments, params);
} }
}
else
{
if (return_type_is_nullable) if (return_type_is_nullable)
{ {
return std::make_shared<AggregateFunctionIfNullVariadic<true, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionIfNullVariadic<true, true>>(nested_function, arguments, params);
} }
else
{
if (need_to_serialize_flag) if (need_to_serialize_flag)
return std::make_shared<AggregateFunctionIfNullVariadic<false, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionIfNullVariadic<false, true>>(nested_function, arguments, params);
else
return std::make_shared<AggregateFunctionIfNullVariadic<false, false>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionIfNullVariadic<false, false>>(nested_function, arguments, params);
} }
}
}
void registerAggregateFunctionCombinatorIf(AggregateFunctionCombinatorFactory & factory) void registerAggregateFunctionCombinatorIf(AggregateFunctionCombinatorFactory & factory)
{ {

View File

@ -450,9 +450,8 @@ public:
auto action = NullsAction::EMPTY; auto action = NullsAction::EMPTY;
return aggr_func_factory.get(nested_func_name + "MappedArrays", action, arguments, params, out_properties); return aggr_func_factory.get(nested_func_name + "MappedArrays", action, arguments, params, out_properties);
} }
else throw Exception(
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Aggregation '{}Map' is not implemented for mapped arrays", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Aggregation '{}Map' is not implemented for mapped arrays", nested_func_name);
nested_func_name);
} }
} }
}; };

View File

@ -112,7 +112,6 @@ public:
*/ */
if (properties.returns_default_when_only_null) if (properties.returns_default_when_only_null)
return std::make_shared<AggregateFunctionNothingUInt64>(arguments, params); return std::make_shared<AggregateFunctionNothingUInt64>(arguments, params);
else
return std::make_shared<AggregateFunctionNothingNull>(arguments, params); return std::make_shared<AggregateFunctionNothingNull>(arguments, params);
} }
@ -137,22 +136,17 @@ public:
{ {
return std::make_shared<AggregateFunctionNullUnary<true, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullUnary<true, true>>(nested_function, arguments, params);
} }
else
{
if (serialize_flag) if (serialize_flag)
return std::make_shared<AggregateFunctionNullUnary<false, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullUnary<false, true>>(nested_function, arguments, params);
else
return std::make_shared<AggregateFunctionNullUnary<false, false>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullUnary<false, false>>(nested_function, arguments, params);
} }
}
else
{
if (return_type_is_nullable) if (return_type_is_nullable)
{ {
return std::make_shared<AggregateFunctionNullVariadic<true, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullVariadic<true, true>>(nested_function, arguments, params);
} }
else
{
return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params);
#if 0 #if 0
if (serialize_flag) if (serialize_flag)
@ -165,8 +159,6 @@ public:
} }
#endif #endif
} }
}
}
}; };
} }

View File

@ -37,7 +37,6 @@ public:
{ {
if (kind == Kind::OrNull) if (kind == Kind::OrNull)
return std::make_shared<AggregateFunctionOrFill<true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionOrFill<true>>(nested_function, arguments, params);
else
return std::make_shared<AggregateFunctionOrFill<false>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionOrFill<false>>(nested_function, arguments, params);
} }
}; };

View File

@ -120,12 +120,10 @@ public:
this->merge(new_sketch); this->merge(new_sketch);
return; return;
} }
else
{
DDSketchDenseLogarithmic new_sketch = changeMapping(other.mapping->getGamma()); DDSketchDenseLogarithmic new_sketch = changeMapping(other.mapping->getGamma());
copy(new_sketch); copy(new_sketch);
} }
}
// If the other sketch is empty, do nothing // If the other sketch is empty, do nothing
if (other.count == 0) if (other.count == 0)

View File

@ -694,7 +694,7 @@ class IAggregateFunctionDataHelper : public IAggregateFunctionHelper<Derived>
protected: protected:
using Data = T; using Data = T;
static Data & data(AggregateDataPtr __restrict place) { return *reinterpret_cast<Data *>(place); } static Data & data(const AggregateDataPtr __restrict place) { return *reinterpret_cast<Data *>(place); }
static const Data & data(ConstAggregateDataPtr __restrict place) { return *reinterpret_cast<const Data *>(place); } static const Data & data(ConstAggregateDataPtr __restrict place) { return *reinterpret_cast<const Data *>(place); }
public: public:

View File

@ -146,7 +146,7 @@ struct QuantileExactExclusive : public QuantileExact<Value>
if (n >= array.size()) if (n >= array.size())
return static_cast<Float64>(*std::max_element(array.begin(), array.end())); return static_cast<Float64>(*std::max_element(array.begin(), array.end()));
else if (n < 1) if (n < 1)
return static_cast<Float64>(*std::min_element(array.begin(), array.end())); return static_cast<Float64>(*std::min_element(array.begin(), array.end()));
::nth_element(array.begin(), array.begin() + n - 1, array.end()); ::nth_element(array.begin(), array.begin() + n - 1, array.end());
@ -211,7 +211,7 @@ struct QuantileExactInclusive : public QuantileExact<Value>
if (n >= array.size()) if (n >= array.size())
return static_cast<Float64>(*std::max_element(array.begin(), array.end())); return static_cast<Float64>(*std::max_element(array.begin(), array.end()));
else if (n < 1) if (n < 1)
return static_cast<Float64>(*std::min_element(array.begin(), array.end())); return static_cast<Float64>(*std::min_element(array.begin(), array.end()));
::nth_element(array.begin(), array.begin() + n - 1, array.end()); ::nth_element(array.begin(), array.begin() + n - 1, array.end());
auto * nth_elem = std::min_element(array.begin() + n, array.end()); auto * nth_elem = std::min_element(array.begin() + n, array.end());

View File

@ -416,15 +416,10 @@ public:
if (x <= left) if (x <= left)
return checkOverflow<ResultType>(prev_mean); return checkOverflow<ResultType>(prev_mean);
else if (x >= right) if (x >= right)
return checkOverflow<ResultType>(c.mean); return checkOverflow<ResultType>(c.mean);
else return checkOverflow<ResultType>(
return checkOverflow<ResultType>(interpolate( interpolate(static_cast<Value>(x), static_cast<Value>(left), prev_mean, static_cast<Value>(right), c.mean));
static_cast<Value>(x),
static_cast<Value>(left),
prev_mean,
static_cast<Value>(right),
c.mean));
} }
sum += c.count; sum += c.count;

View File

@ -736,15 +736,13 @@ public:
tiny.prepare(); tiny.prepare();
return tiny.get(level); return tiny.get(level);
} }
else if (kind == Kind::Medium) if (kind == Kind::Medium)
{ {
return medium.get(level); return medium.get(level);
} }
else
{
return large->get(level); return large->get(level);
} }
}
/// Get the size values of the quantiles of the `levels` levels. Record `size` results starting with `result` address. /// Get the size values of the quantiles of the `levels` levels. Record `size` results starting with `result` address.
template <typename ResultType> template <typename ResultType>

View File

@ -260,7 +260,6 @@ private:
/// With a large number of values, we will generate random numbers several times slower. /// With a large number of values, we will generate random numbers several times slower.
if (limit <= static_cast<UInt64>(pcg32_fast::max())) if (limit <= static_cast<UInt64>(pcg32_fast::max()))
return rng() % limit; return rng() % limit;
else
return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32_fast::max()) + 1ULL) + static_cast<UInt64>(rng())) % limit; return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32_fast::max()) + 1ULL) + static_cast<UInt64>(rng())) % limit;
} }
@ -277,7 +276,6 @@ private:
{ {
if (OnEmpty == ReservoirSamplerOnEmpty::THROW) if (OnEmpty == ReservoirSamplerOnEmpty::THROW)
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSampler"); throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSampler");
else
return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue(); return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue();
} }
}; };

View File

@ -271,7 +271,6 @@ private:
{ {
if (OnEmpty == ReservoirSamplerDeterministicOnEmpty::THROW) if (OnEmpty == ReservoirSamplerDeterministicOnEmpty::THROW)
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSamplerDeterministic"); throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSamplerDeterministic");
else
return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue(); return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue();
} }
}; };

View File

@ -50,8 +50,7 @@ std::optional<size_t> SingleValueDataBase::getSmallestIndex(const IColumn & colu
index = i; index = i;
return {index}; return {index};
} }
else
{
constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Ascending; constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Ascending;
constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable; constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable;
IColumn::Permutation permutation; IColumn::Permutation permutation;
@ -59,7 +58,6 @@ std::optional<size_t> SingleValueDataBase::getSmallestIndex(const IColumn & colu
column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation); column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation);
return {permutation[0]}; return {permutation[0]};
} }
}
std::optional<size_t> SingleValueDataBase::getGreatestIndex(const IColumn & column, size_t row_begin, size_t row_end) const std::optional<size_t> SingleValueDataBase::getGreatestIndex(const IColumn & column, size_t row_begin, size_t row_end) const
{ {
@ -77,8 +75,7 @@ std::optional<size_t> SingleValueDataBase::getGreatestIndex(const IColumn & colu
index = i; index = i;
return {index}; return {index};
} }
else
{
constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Descending; constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Descending;
constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable; constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable;
IColumn::Permutation permutation; IColumn::Permutation permutation;
@ -86,7 +83,6 @@ std::optional<size_t> SingleValueDataBase::getGreatestIndex(const IColumn & colu
column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation); column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation);
return {permutation[0]}; return {permutation[0]};
} }
}
std::optional<size_t> SingleValueDataBase::getSmallestIndexNotNullIf( std::optional<size_t> SingleValueDataBase::getSmallestIndexNotNullIf(
const IColumn & column, const UInt8 * __restrict null_map, const UInt8 * __restrict if_map, size_t row_begin, size_t row_end) const const IColumn & column, const UInt8 * __restrict null_map, const UInt8 * __restrict if_map, size_t row_begin, size_t row_end) const
@ -247,7 +243,6 @@ bool SingleValueDataFixed<T>::setIfSmaller(const SingleValueDataFixed<T> & to, A
set(to, arena); set(to, arena);
return true; return true;
} }
else
return false; return false;
} }
@ -259,7 +254,6 @@ bool SingleValueDataFixed<T>::setIfGreater(const SingleValueDataFixed<T> & to, A
set(to, arena); set(to, arena);
return true; return true;
} }
else
return false; return false;
} }
@ -271,7 +265,6 @@ bool SingleValueDataFixed<T>::setIfSmaller(const IColumn & column, size_t row_nu
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
return false; return false;
} }
@ -283,7 +276,6 @@ bool SingleValueDataFixed<T>::setIfGreater(const IColumn & column, size_t row_nu
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
return false; return false;
} }
@ -544,7 +536,7 @@ std::optional<size_t> SingleValueDataFixed<T>::getGreatestIndexNotNullIf(
} }
return opt; return opt;
} }
else if (!null_map) if (!null_map)
{ {
opt = findExtremeMaxIf(vec.getData().data(), if_map, row_begin, row_end); opt = findExtremeMaxIf(vec.getData().data(), if_map, row_begin, row_end);
if (!opt.has_value()) if (!opt.has_value())
@ -556,8 +548,7 @@ std::optional<size_t> SingleValueDataFixed<T>::getGreatestIndexNotNullIf(
} }
return opt; return opt;
} }
else
{
auto final_flags = mergeIfAndNullFlags(null_map, if_map, row_begin, row_end); auto final_flags = mergeIfAndNullFlags(null_map, if_map, row_begin, row_end);
opt = findExtremeMaxIf(vec.getData().data(), final_flags.get(), row_begin, row_end); opt = findExtremeMaxIf(vec.getData().data(), final_flags.get(), row_begin, row_end);
if (!opt.has_value()) if (!opt.has_value())
@ -567,7 +558,7 @@ std::optional<size_t> SingleValueDataFixed<T>::getGreatestIndexNotNullIf(
if (final_flags[i] && vec[i] == *opt) if (final_flags[i] && vec[i] == *opt)
return {i}; return {i};
} }
}
UNREACHABLE(); UNREACHABLE();
} }
else else
@ -1218,7 +1209,6 @@ bool SingleValueDataString::setIfSmaller(const IColumn & column, size_t row_num,
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
return false; return false;
} }
@ -1230,7 +1220,6 @@ bool SingleValueDataString::setIfSmaller(const SingleValueDataBase & other, Aren
changeImpl(to.getStringRef(), arena); changeImpl(to.getStringRef(), arena);
return true; return true;
} }
else
return false; return false;
} }
@ -1243,7 +1232,6 @@ bool SingleValueDataString::setIfGreater(const IColumn & column, size_t row_num,
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
return false; return false;
} }
@ -1255,7 +1243,6 @@ bool SingleValueDataString::setIfGreater(const SingleValueDataBase & other, Aren
changeImpl(to.getStringRef(), arena); changeImpl(to.getStringRef(), arena);
return true; return true;
} }
else
return false; return false;
} }
@ -1317,8 +1304,7 @@ bool SingleValueDataGeneric::setIfSmaller(const IColumn & column, size_t row_num
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
{
Field new_value; Field new_value;
column.get(row_num, new_value); column.get(row_num, new_value);
if (new_value < value) if (new_value < value)
@ -1326,10 +1312,8 @@ bool SingleValueDataGeneric::setIfSmaller(const IColumn & column, size_t row_num
value = new_value; value = new_value;
return true; return true;
} }
else
return false; return false;
} }
}
bool SingleValueDataGeneric::setIfSmaller(const SingleValueDataBase & other, Arena *) bool SingleValueDataGeneric::setIfSmaller(const SingleValueDataBase & other, Arena *)
{ {
@ -1339,7 +1323,6 @@ bool SingleValueDataGeneric::setIfSmaller(const SingleValueDataBase & other, Are
value = to.value; value = to.value;
return true; return true;
} }
else
return false; return false;
} }
@ -1350,8 +1333,7 @@ bool SingleValueDataGeneric::setIfGreater(const IColumn & column, size_t row_num
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
{
Field new_value; Field new_value;
column.get(row_num, new_value); column.get(row_num, new_value);
if (new_value > value) if (new_value > value)
@ -1359,10 +1341,8 @@ bool SingleValueDataGeneric::setIfGreater(const IColumn & column, size_t row_num
value = new_value; value = new_value;
return true; return true;
} }
else
return false; return false;
} }
}
bool SingleValueDataGeneric::setIfGreater(const SingleValueDataBase & other, Arena *) bool SingleValueDataGeneric::setIfGreater(const SingleValueDataBase & other, Arena *)
{ {
@ -1372,7 +1352,6 @@ bool SingleValueDataGeneric::setIfGreater(const SingleValueDataBase & other, Are
value = to.value; value = to.value;
return true; return true;
} }
else
return false; return false;
} }

View File

@ -60,9 +60,8 @@ public:
{ {
if (sk_union) if (sk_union)
return static_cast<UInt64>(sk_union->get_result().get_estimate()); return static_cast<UInt64>(sk_union->get_result().get_estimate());
else if (sk_update) if (sk_update)
return static_cast<UInt64>(sk_update->get_estimate()); return static_cast<UInt64>(sk_update->get_estimate());
else
return 0; return 0;
} }

View File

@ -26,7 +26,6 @@ bool isAllArgumentsContiguousInMemory(const DataTypes & argument_types)
if (single_argument_as_tuple) if (single_argument_as_tuple)
return check_all_arguments_are_contiguous_in_memory(single_argument_as_tuple->getElements()); return check_all_arguments_are_contiguous_in_memory(single_argument_as_tuple->getElements());
else
return check_all_arguments_are_contiguous_in_memory(argument_types); return check_all_arguments_are_contiguous_in_memory(argument_types);
} }

View File

@ -163,8 +163,7 @@ void ExceptColumnTransformerNode::dumpTreeImpl(WriteBuffer & buffer, FormatState
buffer << ", pattern: " << column_matcher->pattern(); buffer << ", pattern: " << column_matcher->pattern();
return; return;
} }
else
{
buffer << ", identifiers: "; buffer << ", identifiers: ";
size_t except_column_names_size = except_column_names.size(); size_t except_column_names_size = except_column_names.size();
@ -176,7 +175,6 @@ void ExceptColumnTransformerNode::dumpTreeImpl(WriteBuffer & buffer, FormatState
buffer << ", "; buffer << ", ";
} }
} }
}
bool ExceptColumnTransformerNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const bool ExceptColumnTransformerNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const
{ {
@ -190,9 +188,9 @@ bool ExceptColumnTransformerNode::isEqualImpl(const IQueryTreeNode & rhs, Compar
if (!column_matcher && !rhs_column_matcher) if (!column_matcher && !rhs_column_matcher)
return true; return true;
else if (column_matcher && !rhs_column_matcher) if (column_matcher && !rhs_column_matcher)
return false; return false;
else if (!column_matcher && rhs_column_matcher) if (!column_matcher && rhs_column_matcher)
return false; return false;
return column_matcher->pattern() == rhs_column_matcher->pattern(); return column_matcher->pattern() == rhs_column_matcher->pattern();

View File

@ -173,9 +173,9 @@ bool FunctionNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions compar
if (lhs_result_type && rhs_result_type && !lhs_result_type->equals(*rhs_result_type)) if (lhs_result_type && rhs_result_type && !lhs_result_type->equals(*rhs_result_type))
return false; return false;
else if (lhs_result_type && !rhs_result_type) if (lhs_result_type && !rhs_result_type)
return false; return false;
else if (!lhs_result_type && rhs_result_type) if (!lhs_result_type && rhs_result_type)
return false; return false;
return true; return true;

View File

@ -127,9 +127,9 @@ bool IQueryTreeNode::isEqual(const IQueryTreeNode & rhs, CompareOptions compare_
if (!lhs_child && !rhs_child) if (!lhs_child && !rhs_child)
continue; continue;
else if (lhs_child && !rhs_child) if (lhs_child && !rhs_child)
return false; return false;
else if (!lhs_child && rhs_child) if (!lhs_child && rhs_child)
return false; return false;
nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get()); nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get());
@ -150,9 +150,9 @@ bool IQueryTreeNode::isEqual(const IQueryTreeNode & rhs, CompareOptions compare_
if (!lhs_strong_pointer && !rhs_strong_pointer) if (!lhs_strong_pointer && !rhs_strong_pointer)
continue; continue;
else if (lhs_strong_pointer && !rhs_strong_pointer) if (lhs_strong_pointer && !rhs_strong_pointer)
return false; return false;
else if (!lhs_strong_pointer && rhs_strong_pointer) if (!lhs_strong_pointer && rhs_strong_pointer)
return false; return false;
nodes_to_process.emplace_back(lhs_strong_pointer.get(), rhs_strong_pointer.get()); nodes_to_process.emplace_back(lhs_strong_pointer.get(), rhs_strong_pointer.get());

View File

@ -202,7 +202,6 @@ private:
} }
return; return;
} }
else
visit(child); visit(child);
} }

View File

@ -173,9 +173,9 @@ bool MatcherNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const
if (!columns_matcher && !rhs_columns_matcher) if (!columns_matcher && !rhs_columns_matcher)
return true; return true;
else if (columns_matcher && !rhs_columns_matcher) if (columns_matcher && !rhs_columns_matcher)
return false; return false;
else if (!columns_matcher && rhs_columns_matcher) if (!columns_matcher && rhs_columns_matcher)
return false; return false;
return columns_matcher->pattern() == rhs_columns_matcher->pattern(); return columns_matcher->pattern() == rhs_columns_matcher->pattern();

View File

@ -118,9 +118,8 @@ public:
{ {
if (aggregate_function_name == "min") if (aggregate_function_name == "min")
return "max"; return "max";
else if (aggregate_function_name == "max") if (aggregate_function_name == "max")
return "min"; return "min";
else
return aggregate_function_name; return aggregate_function_name;
}; };

View File

@ -486,7 +486,6 @@ CNF & CNF::reduce()
statements = filterCNFSubsets(statements); statements = filterCNFSubsets(statements);
return *this; return *this;
} }
else
statements = new_statements; statements = new_statements;
} }
} }

View File

@ -184,7 +184,7 @@ StorageSnapshotPtr getStorageSnapshot(const QueryTreeNodePtr & node)
StorageSnapshotPtr storage_snapshot{nullptr}; StorageSnapshotPtr storage_snapshot{nullptr};
if (auto * table_node = node->as<TableNode>()) if (auto * table_node = node->as<TableNode>())
return table_node->getStorageSnapshot(); return table_node->getStorageSnapshot();
else if (auto * table_function_node = node->as<TableFunctionNode>()) if (auto * table_function_node = node->as<TableFunctionNode>())
return table_function_node->getStorageSnapshot(); return table_function_node->getStorageSnapshot();
return nullptr; return nullptr;

View File

@ -43,7 +43,6 @@ DataTypePtr getEnumType(const std::set<std::string> & string_values)
{ {
if (string_values.size() >= 255) if (string_values.size() >= 255)
return getDataEnumType<DataTypeEnum16>(string_values); return getDataEnumType<DataTypeEnum16>(string_values);
else
return getDataEnumType<DataTypeEnum8>(string_values); return getDataEnumType<DataTypeEnum8>(string_values);
} }

View File

@ -165,27 +165,26 @@ private:
createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)), createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)),
createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time))); createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)));
} }
else if (comparator == "notEquals") if (comparator == "notEquals")
{ {
return createFunctionNode( return createFunctionNode(
"or", "or",
createFunctionNode("less", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)), createFunctionNode("less", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)),
createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time))); createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)));
} }
else if (comparator == "greater") if (comparator == "greater")
{ {
return createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)); return createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time));
} }
else if (comparator == "lessOrEquals") if (comparator == "lessOrEquals")
{ {
return createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)); return createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time));
} }
else if (comparator == "less" || comparator == "greaterOrEquals") if (comparator == "less" || comparator == "greaterOrEquals")
{ {
return createFunctionNode(comparator, column_node, std::make_shared<ConstantNode>(start_date_or_date_time)); return createFunctionNode(comparator, column_node, std::make_shared<ConstantNode>(start_date_or_date_time));
} }
else [[unlikely]] [[unlikely]] {
{
throw Exception( throw Exception(
ErrorCodes::LOGICAL_ERROR, ErrorCodes::LOGICAL_ERROR,
"Expected equals, notEquals, less, lessOrEquals, greater, greaterOrEquals. Actual {}", "Expected equals, notEquals, less, lessOrEquals, greater, greaterOrEquals. Actual {}",

View File

@ -552,9 +552,9 @@ QueryTreeNodePtr IdentifierResolver::tryResolveIdentifierFromExpressionArguments
auto node_type = it->second->getNodeType(); auto node_type = it->second->getNodeType();
if (identifier_lookup.isExpressionLookup() && !isExpressionNodeType(node_type)) if (identifier_lookup.isExpressionLookup() && !isExpressionNodeType(node_type))
return {}; return {};
else if (identifier_lookup.isTableExpressionLookup() && !isTableExpressionNodeType(node_type)) if (identifier_lookup.isTableExpressionLookup() && !isTableExpressionNodeType(node_type))
return {}; return {};
else if (identifier_lookup.isFunctionLookup() && !isFunctionExpressionNodeType(node_type)) if (identifier_lookup.isFunctionLookup() && !isFunctionExpressionNodeType(node_type))
return {}; return {};
if (!resolve_full_identifier && identifier_lookup.identifier.isCompound() && identifier_lookup.isExpressionLookup()) if (!resolve_full_identifier && identifier_lookup.identifier.isCompound() && identifier_lookup.isExpressionLookup())
@ -638,9 +638,8 @@ bool IdentifierResolver::tryBindIdentifierToTableExpression(const IdentifierLook
if (parts_size == 1 && path_start == table_name) if (parts_size == 1 && path_start == table_name)
return true; return true;
else if (parts_size == 2 && path_start == database_name && identifier[1] == table_name) if (parts_size == 2 && path_start == database_name && identifier[1] == table_name)
return true; return true;
else
return false; return false;
} }
@ -910,9 +909,8 @@ QueryTreeNodePtr IdentifierResolver::tryResolveIdentifierFromTableExpression(con
if (parts_size == 1 && path_start == table_name) if (parts_size == 1 && path_start == table_name)
return table_expression_node; return table_expression_node;
else if (parts_size == 2 && path_start == database_name && identifier[1] == table_name) if (parts_size == 2 && path_start == database_name && identifier[1] == table_name)
return table_expression_node; return table_expression_node;
else
return {}; return {};
} }

View File

@ -1219,9 +1219,10 @@ QueryTreeNodePtr QueryAnalyzer::tryResolveIdentifierFromAliases(const Identifier
scope, scope,
identifier_resolve_settings.allow_to_check_join_tree /* can_be_not_found */); identifier_resolve_settings.allow_to_check_join_tree /* can_be_not_found */);
} }
else if (identifier_lookup.isFunctionLookup() || identifier_lookup.isTableExpressionLookup()) if (identifier_lookup.isFunctionLookup() || identifier_lookup.isTableExpressionLookup())
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"Compound identifier '{}' cannot be resolved as {}. In scope {}", "Compound identifier '{}' cannot be resolved as {}. In scope {}",
identifier_lookup.identifier.getFullName(), identifier_lookup.identifier.getFullName(),
identifier_lookup.isFunctionLookup() ? "function" : "table expression", identifier_lookup.isFunctionLookup() ? "function" : "table expression",
@ -1307,7 +1308,7 @@ IdentifierResolveResult QueryAnalyzer::tryResolveIdentifierInParentScopes(const
{ {
return lookup_result; return lookup_result;
} }
else if (auto * resolved_function = resolved_identifier->as<FunctionNode>()) if (auto * resolved_function = resolved_identifier->as<FunctionNode>())
{ {
/// Special case: scalar subquery was executed and replaced by __getScalar function. /// Special case: scalar subquery was executed and replaced by __getScalar function.
/// Handle it as a constant. /// Handle it as a constant.
@ -3173,14 +3174,14 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
node = std::move(result_list); node = std::move(result_list);
return result_projection_names; return result_projection_names;
} }
else if (function_name == "grouping") if (function_name == "grouping")
{ {
/// It is responsibility of planner to perform additional handling of grouping function /// It is responsibility of planner to perform additional handling of grouping function
if (function_arguments_size == 0) if (function_arguments_size == 0)
throw Exception(ErrorCodes::TOO_FEW_ARGUMENTS_FOR_FUNCTION, throw Exception(ErrorCodes::TOO_FEW_ARGUMENTS_FOR_FUNCTION, "Function GROUPING expects at least one argument");
"Function GROUPING expects at least one argument"); if (function_arguments_size > 64)
else if (function_arguments_size > 64) throw Exception(
throw Exception(ErrorCodes::TOO_MANY_ARGUMENTS_FOR_FUNCTION, ErrorCodes::TOO_MANY_ARGUMENTS_FOR_FUNCTION,
"Function GROUPING can have up to 64 arguments, but {} provided", "Function GROUPING can have up to 64 arguments, but {} provided",
function_arguments_size); function_arguments_size);
checkFunctionNodeHasEmptyNullsAction(function_node); checkFunctionNodeHasEmptyNullsAction(function_node);
@ -3744,8 +3745,8 @@ ProjectionNames QueryAnalyzer::resolveExpressionNode(
resolved_expression_it = resolved_expressions.find(node); resolved_expression_it = resolved_expressions.find(node);
if (resolved_expression_it != resolved_expressions.end()) if (resolved_expression_it != resolved_expressions.end())
return resolved_expression_it->second; return resolved_expression_it->second;
else throw Exception(
throw Exception(ErrorCodes::LOGICAL_ERROR, ErrorCodes::LOGICAL_ERROR,
"Identifier '{}' resolve into list node and list node projection names are not initialized. In scope {}", "Identifier '{}' resolve into list node and list node projection names are not initialized. In scope {}",
unresolved_identifier.getFullName(), unresolved_identifier.getFullName(),
scope.scope_node->formatASTForErrorMessage()); scope.scope_node->formatASTForErrorMessage());
@ -4212,7 +4213,7 @@ NamesAndTypes QueryAnalyzer::resolveProjectionExpressionNodeList(QueryTreeNodePt
for (size_t i = 0; i < projection_nodes_size; ++i) for (size_t i = 0; i < projection_nodes_size; ++i)
{ {
auto projection_node = projection_nodes[i]; const auto & projection_node = projection_nodes[i];
if (!IdentifierResolver::isExpressionNodeType(projection_node->getNodeType())) if (!IdentifierResolver::isExpressionNodeType(projection_node->getNodeType()))
throw Exception(ErrorCodes::UNSUPPORTED_METHOD, throw Exception(ErrorCodes::UNSUPPORTED_METHOD,
@ -4628,10 +4629,7 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
"Unknown table function {}. Maybe you meant: {}", "Unknown table function {}. Maybe you meant: {}",
table_function_name, table_function_name,
DB::toString(hints)); DB::toString(hints));
else throw Exception(ErrorCodes::UNKNOWN_FUNCTION, "Unknown table function {}", table_function_name);
throw Exception(ErrorCodes::UNKNOWN_FUNCTION,
"Unknown table function {}",
table_function_name);
} }
QueryTreeNodes result_table_function_arguments; QueryTreeNodes result_table_function_arguments;
@ -4667,7 +4665,7 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
continue; continue;
} }
else if (auto * table_function_argument_function = table_function_argument->as<FunctionNode>()) if (auto * table_function_argument_function = table_function_argument->as<FunctionNode>())
{ {
const auto & table_function_argument_function_name = table_function_argument_function->getFunctionName(); const auto & table_function_argument_function_name = table_function_argument_function->getFunctionName();
if (TableFunctionFactory::instance().isTableFunctionName(table_function_argument_function_name)) if (TableFunctionFactory::instance().isTableFunctionName(table_function_argument_function_name))

View File

@ -50,7 +50,7 @@ public:
updateAliasesIfNeeded(child, true /*is_lambda_node*/); updateAliasesIfNeeded(child, true /*is_lambda_node*/);
return false; return false;
} }
else if (auto * query_tree_node = child->as<QueryNode>()) if (auto * query_tree_node = child->as<QueryNode>())
{ {
if (query_tree_node->isCTE()) if (query_tree_node->isCTE())
return false; return false;
@ -58,7 +58,7 @@ public:
updateAliasesIfNeeded(child, false /*is_lambda_node*/); updateAliasesIfNeeded(child, false /*is_lambda_node*/);
return false; return false;
} }
else if (auto * union_node = child->as<UnionNode>()) if (auto * union_node = child->as<UnionNode>())
{ {
if (union_node->isCTE()) if (union_node->isCTE())
return false; return false;

View File

@ -81,9 +81,9 @@ bool SortNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const
if (!collator && !rhs_typed.collator) if (!collator && !rhs_typed.collator)
return true; return true;
else if (collator && !rhs_typed.collator) if (collator && !rhs_typed.collator)
return false; return false;
else if (!collator && rhs_typed.collator) if (!collator && rhs_typed.collator)
return false; return false;
return collator->getLocale() == rhs_typed.collator->getLocale(); return collator->getLocale() == rhs_typed.collator->getLocale();

View File

@ -170,7 +170,7 @@ bool UnionNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const
if (recursive_cte_table && rhs_typed.recursive_cte_table && if (recursive_cte_table && rhs_typed.recursive_cte_table &&
recursive_cte_table->getStorageID() != rhs_typed.recursive_cte_table->getStorageID()) recursive_cte_table->getStorageID() != rhs_typed.recursive_cte_table->getStorageID())
return false; return false;
else if ((recursive_cte_table && !rhs_typed.recursive_cte_table) || (!recursive_cte_table && rhs_typed.recursive_cte_table)) if ((recursive_cte_table && !rhs_typed.recursive_cte_table) || (!recursive_cte_table && rhs_typed.recursive_cte_table))
return false; return false;
return is_subquery == rhs_typed.is_subquery && is_cte == rhs_typed.is_cte && is_recursive_cte == rhs_typed.is_recursive_cte return is_subquery == rhs_typed.is_subquery && is_cte == rhs_typed.is_cte && is_recursive_cte == rhs_typed.is_recursive_cte

View File

@ -156,19 +156,19 @@ std::string getGlobalInFunctionNameForLocalInFunctionName(const std::string & fu
{ {
if (function_name == "in") if (function_name == "in")
return "globalIn"; return "globalIn";
else if (function_name == "notIn") if (function_name == "notIn")
return "globalNotIn"; return "globalNotIn";
else if (function_name == "nullIn") if (function_name == "nullIn")
return "globalNullIn"; return "globalNullIn";
else if (function_name == "notNullIn") if (function_name == "notNullIn")
return "globalNotNullIn"; return "globalNotNullIn";
else if (function_name == "inIgnoreSet") if (function_name == "inIgnoreSet")
return "globalInIgnoreSet"; return "globalInIgnoreSet";
else if (function_name == "notInIgnoreSet") if (function_name == "notInIgnoreSet")
return "globalNotInIgnoreSet"; return "globalNotInIgnoreSet";
else if (function_name == "nullInIgnoreSet") if (function_name == "nullInIgnoreSet")
return "globalNullInIgnoreSet"; return "globalNullInIgnoreSet";
else if (function_name == "notNullInIgnoreSet") if (function_name == "notNullInIgnoreSet")
return "globalNotNullInIgnoreSet"; return "globalNotNullInIgnoreSet";
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid local IN function name {}", function_name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid local IN function name {}", function_name);

View File

@ -173,9 +173,9 @@ private:
if (!lhs_child && !rhs_child) if (!lhs_child && !rhs_child)
continue; continue;
else if (lhs_child && !rhs_child) if (lhs_child && !rhs_child)
return false; return false;
else if (!lhs_child && rhs_child) if (!lhs_child && rhs_child)
return false; return false;
nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get()); nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get());

View File

@ -182,18 +182,16 @@ Strings BackupEntriesCollector::setStage(const String & new_stage, const String
{ {
return backup_coordination->waitForStage(new_stage, on_cluster_first_sync_timeout); return backup_coordination->waitForStage(new_stage, on_cluster_first_sync_timeout);
} }
else if (new_stage.starts_with(Stage::GATHERING_METADATA)) if (new_stage.starts_with(Stage::GATHERING_METADATA))
{ {
auto current_time = std::chrono::steady_clock::now(); auto current_time = std::chrono::steady_clock::now();
auto end_of_timeout = std::max(current_time, collect_metadata_end_time); auto end_of_timeout = std::max(current_time, collect_metadata_end_time);
return backup_coordination->waitForStage( return backup_coordination->waitForStage(
new_stage, std::chrono::duration_cast<std::chrono::milliseconds>(end_of_timeout - current_time)); new_stage, std::chrono::duration_cast<std::chrono::milliseconds>(end_of_timeout - current_time));
} }
else
{
return backup_coordination->waitForStage(new_stage); return backup_coordination->waitForStage(new_stage);
} }
}
void BackupEntriesCollector::checkIsQueryCancelled() const void BackupEntriesCollector::checkIsQueryCancelled() const
{ {
@ -716,23 +714,20 @@ bool BackupEntriesCollector::compareWithPrevious(String & mismatch_description)
{ {
if (mismatch->first == p_mismatch->first) if (mismatch->first == p_mismatch->first)
return {MismatchType::CHANGED, mismatch->first}; return {MismatchType::CHANGED, mismatch->first};
else if (mismatch->first < p_mismatch->first) if (mismatch->first < p_mismatch->first)
return {MismatchType::ADDED, mismatch->first}; return {MismatchType::ADDED, mismatch->first};
else
return {MismatchType::REMOVED, mismatch->first}; return {MismatchType::REMOVED, mismatch->first};
} }
else if (mismatch != metadata.end()) if (mismatch != metadata.end())
{ {
return {MismatchType::ADDED, mismatch->first}; return {MismatchType::ADDED, mismatch->first};
} }
else if (p_mismatch != previous_metadata.end()) if (p_mismatch != previous_metadata.end())
{ {
return {MismatchType::REMOVED, p_mismatch->first}; return {MismatchType::REMOVED, p_mismatch->first};
} }
else
{
return {MismatchType::NONE, {}}; return {MismatchType::NONE, {}};
}
}; };
/// Databases must be the same as during the previous scan. /// Databases must be the same as during the previous scan.

View File

@ -14,9 +14,8 @@ namespace
{ {
if (!unencrypted_file_size) if (!unencrypted_file_size)
return copy_encrypted ? disk->getEncryptedFileSize(file_path) : disk->getFileSize(file_path); return copy_encrypted ? disk->getEncryptedFileSize(file_path) : disk->getFileSize(file_path);
else if (copy_encrypted) if (copy_encrypted)
return disk->getEncryptedFileSize(*unencrypted_file_size); return disk->getEncryptedFileSize(*unencrypted_file_size);
else
return *unencrypted_file_size; return *unencrypted_file_size;
} }
} }

View File

@ -39,7 +39,6 @@ std::unique_ptr<SeekableReadBuffer> BackupEntryFromImmutableFile::getReadBuffer(
{ {
if (copy_encrypted) if (copy_encrypted)
return disk->readEncryptedFile(file_path, read_settings); return disk->readEncryptedFile(file_path, read_settings);
else
return disk->readFile(file_path, read_settings); return disk->readFile(file_path, read_settings);
} }

Some files were not shown because too many files have changed in this diff Show More