15 package com.cloudera.impala.analysis;
17 import java.util.regex.Pattern;
18 import java.util.regex.PatternSyntaxException;
25 import com.cloudera.impala.thrift.TExprNode;
26 import com.cloudera.impala.thrift.TExprNodeType;
27 import com.google.common.base.Preconditions;
28 import com.google.common.collect.Lists;
39 this.description_ = description;
49 db.addBuiltin(ScalarFunction.createBuiltin(
51 false,
Type.BOOLEAN,
"_ZN6impala13LikePredicate4LikeEPN10impala_udf15FunctionContextERKNS1_9StringValES6_",
"_ZN6impala13LikePredicate11LikePrepareEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE",
52 "_ZN6impala13LikePredicate9LikeCloseEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE",
true));
53 db.addBuiltin(ScalarFunction.createBuiltin(
55 false,
Type.BOOLEAN,
"_ZN6impala13LikePredicate5RegexEPN10impala_udf15FunctionContextERKNS1_9StringValES6_",
"_ZN6impala13LikePredicate12RegexPrepareEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE",
56 "_ZN6impala13LikePredicate10RegexCloseEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE",
true));
57 db.addBuiltin(ScalarFunction.createBuiltin(
59 false,
Type.BOOLEAN,
"_ZN6impala13LikePredicate5RegexEPN10impala_udf15FunctionContextERKNS1_9StringValES6_",
"_ZN6impala13LikePredicate12RegexPrepareEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE",
60 "_ZN6impala13LikePredicate10RegexCloseEPN10impala_udf15FunctionContextENS2_18FunctionStateScopeE",
true));
68 Preconditions.checkNotNull(e1);
70 Preconditions.checkNotNull(e2);
86 if (!super.equals(obj))
return false;
92 return getChild(0).toSql() +
" " +
op_.
toString() +
" " + getChild(1).toSql();
97 msg.node_type = TExprNodeType.FUNCTION_CALL;
103 super.analyze(analyzer);
104 if (!getChild(0).getType().isStringType() && !getChild(0).getType().isNull()) {
106 "left operand of " +
op_.
toString() +
" must be of type STRING: " +
toSql());
108 if (!getChild(1).getType().isStringType() && !getChild(1).getType().isNull()) {
110 "right operand of " +
op_.
toString() +
" must be of type STRING: " +
toSql());
115 Preconditions.checkState(
fn_ != null);
116 Preconditions.checkState(fn_.getReturnType().isBoolean());
118 if (getChild(1).isLiteral() && !getChild(1).isNullLiteral()
125 }
catch (PatternSyntaxException e) {
127 "invalid regular expression in '" + this.
toSql() +
"'");
Operator(String description)
void castForFunctionCall(boolean ignoreWildcardDecimals)
static final ScalarType STRING
static final ScalarType BOOLEAN
Type[] collectChildReturnTypes()
LikePredicate(LikePredicate other)
LikePredicate(Operator op, Expr e1, Expr e2)
void analyze(Analyzer analyzer)
void toThrift(TExprNode msg)
Function getBuiltinFunction(Analyzer analyzer, String name, Type[] argTypes, CompareMode mode)
boolean equals(Object obj)
static void initBuiltins(Db db)
final String description_