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-23 07:47:17 +00:00
|
|
|
return name == "joinGet" || startsWith(name, "dictGet");
|
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)
|
|
|
|
throw Exception("Wrong number of arguments passed to function in. Expected: 2, passed: " + std::to_string(num_arguments),
|
|
|
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-23 13:59:03 +00:00
|
|
|
}
|