Search in sources :

Example 6 with FuncHolder

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;
    }
}
Also used : DrillSimpleFuncHolder(org.apache.drill.exec.expr.fn.DrillSimpleFuncHolder) FuncHolder(org.apache.drill.common.expression.fn.FuncHolder) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) ValueHolder(org.apache.drill.exec.expr.holders.ValueHolder) DrillSimpleFuncHolder(org.apache.drill.exec.expr.fn.DrillSimpleFuncHolder)

Aggregations

FuncHolder (org.apache.drill.common.expression.fn.FuncHolder)6 DrillSimpleFuncHolder (org.apache.drill.exec.expr.fn.DrillSimpleFuncHolder)6 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)3 ValueHolder (org.apache.drill.exec.expr.holders.ValueHolder)3 ColumnStatistics (org.apache.drill.exec.store.parquet.stat.ColumnStatistics)2 DoubleStatistics (org.apache.parquet.column.statistics.DoubleStatistics)2 FloatStatistics (org.apache.parquet.column.statistics.FloatStatistics)2 IntStatistics (org.apache.parquet.column.statistics.IntStatistics)2 LongStatistics (org.apache.parquet.column.statistics.LongStatistics)2 Statistics (org.apache.parquet.column.statistics.Statistics)2 ArrayList (java.util.ArrayList)1 ColumnStatistics (org.apache.drill.metastore.statistics.ColumnStatistics)1 BooleanStatistics (org.apache.parquet.column.statistics.BooleanStatistics)1