use of org.apache.drill.common.expression.fn.FuncHolder in project drill by apache.
the class ParquetFilterBuilder method visitFunctionHolderExpression.
@Override
public LogicalExpression visitFunctionHolderExpression(FunctionHolderExpression funcHolderExpr, Set<LogicalExpression> value) throws RuntimeException {
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);
}
if (CastFunctions.isCastFunction(funcName)) {
List<LogicalExpression> newArgs = new ArrayList();
for (LogicalExpression arg : funcHolderExpr.args) {
final LogicalExpression newArg = arg.accept(this, value);
if (newArg == null) {
return null;
}
newArgs.add(newArg);
}
return funcHolderExpr.copy(newArgs);
} else {
return null;
}
}
use of org.apache.drill.common.expression.fn.FuncHolder in project drill by axbaretto.
the class RangeExprEvaluator method visitFunctionHolderExpression.
@Override
public Statistics visitFunctionHolderExpression(FunctionHolderExpression holderExpr, Void value) throws RuntimeException {
FuncHolder funcHolder = holderExpr.getHolder();
if (!(funcHolder instanceof DrillSimpleFuncHolder)) {
// Only Drill function is allowed.
return null;
}
final String funcName = ((DrillSimpleFuncHolder) funcHolder).getRegisteredNames()[0];
if (CastFunctions.isCastFunction(funcName)) {
Statistics stat = holderExpr.args.get(0).accept(this, null);
if (stat != null && !stat.isEmpty()) {
return evalCastFunc(holderExpr, stat);
}
}
return null;
}
use of org.apache.drill.common.expression.fn.FuncHolder in project drill by axbaretto.
the class ParquetFilterBuilder method visitFunctionHolderExpression.
@Override
public LogicalExpression visitFunctionHolderExpression(FunctionHolderExpression funcHolderExpr, Set<LogicalExpression> value) throws RuntimeException {
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);
}
if (isIsFunction(funcName)) {
return handleIsFunction(funcHolderExpr, value);
}
if (CastFunctions.isCastFunction(funcName)) {
List<LogicalExpression> newArgs = generateNewExpressions(funcHolderExpr.args, value);
if (newArgs == null) {
return null;
}
return funcHolderExpr.copy(newArgs);
} else {
return null;
}
}
use of org.apache.drill.common.expression.fn.FuncHolder in project drill by apache.
the class StatisticsProvider method visitFunctionHolderExpression.
@Override
@SuppressWarnings("unchecked")
public ColumnStatistics<?> visitFunctionHolderExpression(FunctionHolderExpression holderExpr, Void value) {
FuncHolder funcHolder = holderExpr.getHolder();
if (!(funcHolder instanceof DrillSimpleFuncHolder)) {
// Only Drill function is allowed.
return null;
}
String funcName = ((DrillSimpleFuncHolder) funcHolder).getRegisteredNames()[0];
if (FunctionReplacementUtils.isCastFunction(funcName)) {
ColumnStatistics<T> stat = (ColumnStatistics<T>) holderExpr.args.get(0).accept(this, null);
if (!IsPredicate.isNullOrEmpty(stat)) {
return evalCastFunc(holderExpr, stat);
}
}
return null;
}
use of org.apache.drill.common.expression.fn.FuncHolder in project drill by apache.
the class RangeExprEvaluator method visitFunctionHolderExpression.
@Override
public Statistics visitFunctionHolderExpression(FunctionHolderExpression holderExpr, Void value) throws RuntimeException {
FuncHolder funcHolder = holderExpr.getHolder();
if (!(funcHolder instanceof DrillSimpleFuncHolder)) {
// Only Drill function is allowed.
return null;
}
final String funcName = ((DrillSimpleFuncHolder) funcHolder).getRegisteredNames()[0];
if (CastFunctions.isCastFunction(funcName)) {
Statistics stat = holderExpr.args.get(0).accept(this, null);
if (stat != null && !stat.isEmpty()) {
return evalCastFunc(holderExpr, stat);
}
}
return null;
}
Aggregations