ClickHouse/src/Interpreters/misc.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.4 KiB
C++
Raw Normal View History

#pragma once
2019-12-21 17:48:33 +00:00
#include <Common/StringUtils/StringUtils.h>
#include <Parsers/ASTFunction.h>
2019-12-21 17:48:33 +00:00
namespace DB
{
namespace ErrorCodes
{
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
inline bool functionIsInOperator(const std::string & name)
{
2020-04-06 13:30:16 +00:00
return name == "in" || name == "notIn" || name == "nullIn" || name == "notNullIn";
}
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";
}
inline bool functionIsLikeOperator(const std::string & name)
{
return name == "like" || name == "ilike" || name == "notLike" || name == "notILike";
}
inline bool functionIsJoinGet(const std::string & name)
2019-12-21 17:48:33 +00:00
{
return startsWith(name, "joinGet");
2019-12-21 17:48:33 +00:00
}
inline bool functionIsDictGet(const std::string & name)
{
return startsWith(name, "dictGet") || (name == "dictHas") || (name == "dictIsIn");
}
inline bool checkFunctionIsInOrGlobalInOperator(const ASTFunction & func)
{
if (functionIsInOrGlobalInOperator(func.name))
{
size_t num_arguments = func.arguments->children.size();
if (num_arguments != 2)
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
"Wrong number of arguments passed to function in. Expected: 2, passed: {}",
num_arguments);
return true;
}
return false;
}
}