blob: c009808de3f7415d0f194d119567f91589ff83f7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#pragma once
#include <Common/StringUtils/StringUtils.h>
#include <Parsers/ASTFunction.h>
namespace DB
{
namespace ErrorCodes
{
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
inline bool functionIsInOperator(const std::string & name)
{
return name == "in" || name == "notIn" || name == "nullIn" || name == "notNullIn";
}
inline bool functionIsInOrGlobalInOperator(const std::string & name)
{
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)
{
return startsWith(name, "joinGet");
}
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;
}
}
|