2019-10-23 13:59:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-12-21 17:48:33 +00:00
|
|
|
#include <Common/StringUtils/StringUtils.h>
|
2020-07-15 14:22:54 +00:00
|
|
|
#include <Parsers/ASTFunction.h>
|
2019-12-21 17:48:33 +00:00
|
|
|
|
2019-10-23 13:59:03 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-07-15 14:22:54 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
|
|
|
}
|
|
|
|
|
2019-10-23 13:59:03 +00:00
|
|
|
inline bool functionIsInOperator(const std::string & name)
|
|
|
|
{
|
2020-04-06 13:30:16 +00:00
|
|
|
return name == "in" || name == "notIn" || name == "nullIn" || name == "notNullIn";
|
2019-10-23 13:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool functionIsInOrGlobalInOperator(const std::string & name)
|
|
|
|
{
|
2020-04-06 13:30:16 +00:00
|
|
|
return functionIsInOperator(name) || name == "globalIn" || name == "globalNotIn" || name == "globalNullIn" || name == "globalNotNullIn";
|
2019-10-23 13:59:03 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 17:22:16 +00:00
|
|
|
inline bool functionIsLikeOperator(const std::string & name)
|
|
|
|
{
|
2020-07-05 15:57:59 +00:00
|
|
|
return name == "like" || name == "ilike" || name == "notLike" || name == "notILike";
|
2020-02-19 17:22:16 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 18:12:30 +00:00
|
|
|
inline bool functionIsJoinGet(const std::string & name)
|
2019-12-21 17:48:33 +00:00
|
|
|
{
|
2020-07-11 07:12:42 +00:00
|
|
|
return startsWith(name, "joinGet");
|
2019-12-21 17:48:33 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 18:12:30 +00:00
|
|
|
inline bool functionIsDictGet(const std::string & name)
|
|
|
|
{
|
|
|
|
return startsWith(name, "dictGet") || (name == "dictHas") || (name == "dictIsIn");
|
|
|
|
}
|
|
|
|
|
2020-07-15 14:22:54 +00:00
|
|
|
inline bool checkFunctionIsInOrGlobalInOperator(const ASTFunction & func)
|
|
|
|
{
|
|
|
|
if (functionIsInOrGlobalInOperator(func.name))
|
|
|
|
{
|
|
|
|
size_t num_arguments = func.arguments->children.size();
|
|
|
|
if (num_arguments != 2)
|
2023-01-23 21:13:58 +00:00
|
|
|
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
|
|
|
|
"Wrong number of arguments passed to function in. Expected: 2, passed: {}",
|
|
|
|
num_arguments);
|
2020-07-15 14:22:54 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-23 13:59:03 +00:00
|
|
|
}
|