use of org.apache.drill.common.expression.fn.FuncHolder in project drill by apache.
the class FilterBuilder method visitFunctionHolderExpression.
@Override
public LogicalExpression visitFunctionHolderExpression(FunctionHolderExpression funcHolderExpr, Set<LogicalExpression> value) {
FuncHolder holder = funcHolderExpr.getHolder();
if (!(holder instanceof DrillSimpleFuncHolder)) {
return null;
}
if (value.contains(funcHolderExpr)) {
ValueHolder result;
try {
result = InterpreterEvaluator.evaluateConstantExpr(udfUtilities, funcHolderExpr);
} catch (Exception e) {
logger.warn("Error in evaluating function of {}", funcHolderExpr.getName());
return null;
}
logger.debug("Reduce a constant function expression into a value expression");
return getValueExpressionFromConst(result, funcHolderExpr.getMajorType().getMinorType());
}
final String funcName = ((DrillSimpleFuncHolder) holder).getRegisteredNames()[0];
if (isCompareFunction(funcName)) {
return handleCompareFunction(funcHolderExpr, value);
} else if (isIsFunction(funcName) || isNot(funcHolderExpr, funcName)) {
return handleIsFunction(funcHolderExpr, value);
} else if (FunctionReplacementUtils.isCastFunction(funcName)) {
List<LogicalExpression> newArgs = generateNewExpressions(funcHolderExpr.args, value);
if (newArgs == null) {
return null;
} else {
return funcHolderExpr.copy(newArgs);
}
} else {
return null;
}
}
Aggregations