Search in sources :

Example 36 with ErrorCollectorImpl

use of org.apache.drill.common.expression.ErrorCollectorImpl in project drill by apache.

the class ExpressionTreeMaterializerTest method testMaterializingLateboundTree.

@Test
public void testMaterializingLateboundTree() throws SchemaChangeException {
    final RecordBatch batch = mock(RecordBatch.class);
    TypedFieldId fieldId = new TypedFieldId.Builder().finalType(Types.required(MinorType.BIT)).addId(-4).build();
    TypedFieldId fieldId2 = new TypedFieldId.Builder().finalType(Types.required(MinorType.BIGINT)).addId(-5).build();
    when(batch.getValueVectorId(SchemaPath.getSimplePath("test"))).thenReturn(fieldId);
    when(batch.getValueVectorId(SchemaPath.getSimplePath("test1"))).thenReturn(fieldId2);
    ErrorCollector ec = new ErrorCollectorImpl();
    LogicalExpression elseExpression = new IfExpression.Builder().setElse(new ValueExpressions.LongExpression(1L, ExpressionPosition.UNKNOWN)).setIfCondition(new IfExpression.IfCondition(new ValueExpressions.BooleanExpression("true", ExpressionPosition.UNKNOWN), new FieldReference("test1", ExpressionPosition.UNKNOWN))).build();
    LogicalExpression expr = new IfExpression.Builder().setIfCondition(new IfExpression.IfCondition(new FieldReference("test", ExpressionPosition.UNKNOWN), new ValueExpressions.LongExpression(2L, ExpressionPosition.UNKNOWN))).setElse(elseExpression).build();
    LogicalExpression newExpr = ExpressionTreeMaterializer.materialize(expr, batch, ec, registry);
    assertTrue(newExpr instanceof IfExpression);
    IfExpression newIfExpr = (IfExpression) newExpr;
    IfExpression.IfCondition ifCondition = newIfExpr.ifCondition;
    assertTrue(newIfExpr.elseExpression instanceof IfExpression);
    assertEquals(bigIntType, ifCondition.expression.getMajorType());
    assertEquals(true, ((ValueExpressions.BooleanExpression) ((IfExpression) (newIfExpr.elseExpression)).ifCondition.condition).value);
    assertFalse(ec.hasErrors());
}
Also used : IfExpression(org.apache.drill.common.expression.IfExpression) FieldReference(org.apache.drill.common.expression.FieldReference) ValueExpressions(org.apache.drill.common.expression.ValueExpressions) ErrorCollector(org.apache.drill.common.expression.ErrorCollector) ErrorCollectorImpl(org.apache.drill.common.expression.ErrorCollectorImpl) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) ExecTest(org.apache.drill.exec.ExecTest) Test(org.junit.Test) VectorTest(org.apache.drill.categories.VectorTest)

Example 37 with ErrorCollectorImpl

use of org.apache.drill.common.expression.ErrorCollectorImpl in project drill by apache.

the class UnionAllRecordBatch method createUnionAller.

private void createUnionAller(RecordBatch inputBatch) {
    transfers.clear();
    allocationVectors.clear();
    ClassGenerator<UnionAller> cg = CodeGenerator.getRoot(UnionAller.TEMPLATE_DEFINITION, context.getOptions());
    cg.getCodeGenerator().plainJavaCapable(true);
    // cg.getCodeGenerator().saveCodeForDebugging(true);
    int index = 0;
    for (VectorWrapper<?> vw : inputBatch) {
        ValueVector vvIn = vw.getValueVector();
        ValueVector vvOut = container.getValueVector(index).getValueVector();
        MaterializedField inField = vvIn.getField();
        MaterializedField outputField = vvOut.getField();
        ErrorCollector collector = new ErrorCollectorImpl();
        // cast data types (MinorType or DataMode)
        if (areAssignableTypes(inField.getType(), outputField.getType())) {
            // Transfer column
            TransferPair tp = vvIn.makeTransferPair(vvOut);
            transfers.add(tp);
        } else if (inField.getType().getMinorType() == TypeProtos.MinorType.NULL) {
            index++;
            continue;
        } else {
            // Copy data in order to rename the column
            SchemaPath inputPath = SchemaPath.getSimplePath(inField.getName());
            LogicalExpression expr = ExpressionTreeMaterializer.materialize(inputPath, inputBatch, collector, context.getFunctionRegistry());
            collector.reportErrors(logger);
            // cast to the one with the least restriction
            if (inField.getType().getMode() == TypeProtos.DataMode.REQUIRED && outputField.getType().getMode() != TypeProtos.DataMode.REQUIRED) {
                expr = ExpressionTreeMaterializer.convertToNullableType(expr, inField.getType().getMinorType(), context.getFunctionRegistry(), collector);
                collector.reportErrors(logger);
            }
            // inserts a cast before the Union operation
            if (isCastRequired(inField.getType(), outputField.getType())) {
                expr = ExpressionTreeMaterializer.addCastExpression(expr, outputField.getType(), context.getFunctionRegistry(), collector);
                collector.reportErrors(logger);
            }
            TypedFieldId fid = container.getValueVectorId(SchemaPath.getSimplePath(outputField.getName()));
            boolean useSetSafe = !(vvOut instanceof FixedWidthVector);
            ValueVectorWriteExpression write = new ValueVectorWriteExpression(fid, expr, useSetSafe);
            cg.addExpr(write);
            allocationVectors.add(vvOut);
        }
        ++index;
    }
    unionall = context.getImplementationClass(cg.getCodeGenerator());
    try {
        unionall.setup(context, inputBatch, this, transfers);
    } catch (SchemaChangeException e) {
        throw schemaChangeException(e, logger);
    }
}
Also used : TransferPair(org.apache.drill.exec.record.TransferPair) FixedWidthVector(org.apache.drill.exec.vector.FixedWidthVector) MaterializedField(org.apache.drill.exec.record.MaterializedField) ErrorCollector(org.apache.drill.common.expression.ErrorCollector) ValueVector(org.apache.drill.exec.vector.ValueVector) ErrorCollectorImpl(org.apache.drill.common.expression.ErrorCollectorImpl) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) SchemaChangeException(org.apache.drill.exec.exception.SchemaChangeException) SchemaPath(org.apache.drill.common.expression.SchemaPath) TypedFieldId(org.apache.drill.exec.record.TypedFieldId) ValueVectorWriteExpression(org.apache.drill.exec.expr.ValueVectorWriteExpression)

Example 38 with ErrorCollectorImpl

use of org.apache.drill.common.expression.ErrorCollectorImpl in project drill by apache.

the class BaseSortWrapper method generateComparisons.

protected void generateComparisons(ClassGenerator<?> g, VectorAccessible batch, org.slf4j.Logger logger) {
    g.setMappingSet(MAIN_MAPPING);
    Sort popConfig = context.getOperatorDefn();
    for (Ordering od : popConfig.getOrderings()) {
        // first, we rewrite the evaluation stack for each side of the comparison.
        ErrorCollector collector = new ErrorCollectorImpl();
        final LogicalExpression expr = ExpressionTreeMaterializer.materialize(od.getExpr(), batch, collector, context.getFragmentContext().getFunctionRegistry());
        if (collector.hasErrors()) {
            throw UserException.unsupportedError().message("Failure while materializing expression. " + collector.toErrorString()).build(logger);
        }
        g.setMappingSet(LEFT_MAPPING);
        HoldingContainer left = g.addExpr(expr, ClassGenerator.BlkCreateMode.FALSE);
        g.setMappingSet(RIGHT_MAPPING);
        HoldingContainer right = g.addExpr(expr, ClassGenerator.BlkCreateMode.FALSE);
        g.setMappingSet(MAIN_MAPPING);
        // next we wrap the two comparison sides and add the expression block for the comparison.
        LogicalExpression fh = FunctionGenerationHelper.getOrderingComparator(od.nullsSortHigh(), left, right, context.getFragmentContext().getFunctionRegistry());
        HoldingContainer out = g.addExpr(fh, ClassGenerator.BlkCreateMode.FALSE);
        JConditional jc = g.getEvalBlock()._if(out.getValue().ne(JExpr.lit(0)));
        if (od.getDirection() == Direction.ASCENDING) {
            jc._then()._return(out.getValue());
        } else {
            jc._then()._return(out.getValue().minus());
        }
        g.rotateBlock();
    }
    g.rotateBlock();
    g.getEvalBlock()._return(JExpr.lit(0));
}
Also used : ErrorCollectorImpl(org.apache.drill.common.expression.ErrorCollectorImpl) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) HoldingContainer(org.apache.drill.exec.expr.ClassGenerator.HoldingContainer) Ordering(org.apache.drill.common.logical.data.Order.Ordering) Sort(org.apache.drill.exec.physical.config.Sort) ErrorCollector(org.apache.drill.common.expression.ErrorCollector) JConditional(com.sun.codemodel.JConditional)

Example 39 with ErrorCollectorImpl

use of org.apache.drill.common.expression.ErrorCollectorImpl in project drill by apache.

the class FunctionGenerationHelper method getOrderingComparator.

/**
 * Finds ordering comparator ("compare_to...") FunctionHolderExpression with
 * a specified ordering for NULL (and considering NULLS <i>equal</i>).
 * @param  null_high  whether NULL should compare as the lowest value (if
 *                    {@code false}) or the highest value (if {@code true})
 * @param  left  ...
 * @param  right  ...
 * @param  functionLookupContext  ...
 * @return
 *     FunctionHolderExpression containing the found function implementation
 */
public static LogicalExpression getOrderingComparator(boolean null_high, HoldingContainer left, HoldingContainer right, FunctionLookupContext functionLookupContext) {
    final String comparator_name = null_high ? COMPARE_TO_NULLS_HIGH : COMPARE_TO_NULLS_LOW;
    if (!isComparableType(left.getMajorType()) || !isComparableType(right.getMajorType())) {
        throw new UnsupportedOperationException(formatCanNotCompareMsg(left.getMajorType(), right.getMajorType()));
    }
    LogicalExpression comparisonFunctionExpression = getFunctionExpression(comparator_name, left, right);
    ErrorCollector collector = new ErrorCollectorImpl();
    if (!isUnionType(left.getMajorType()) && !isUnionType(right.getMajorType())) {
        return ExpressionTreeMaterializer.materialize(comparisonFunctionExpression, null, collector, functionLookupContext);
    } else {
        LogicalExpression typeComparisonFunctionExpression = getTypeComparisonFunction(comparisonFunctionExpression, left, right);
        return ExpressionTreeMaterializer.materialize(typeComparisonFunctionExpression, null, collector, functionLookupContext);
    }
}
Also used : ErrorCollectorImpl(org.apache.drill.common.expression.ErrorCollectorImpl) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) ErrorCollector(org.apache.drill.common.expression.ErrorCollector)

Example 40 with ErrorCollectorImpl

use of org.apache.drill.common.expression.ErrorCollectorImpl in project drill by apache.

the class DrillConstExecutor method reduce.

@Override
@SuppressWarnings("deprecation")
public void reduce(RexBuilder rexBuilder, List<RexNode> constExps, List<RexNode> reducedValues) {
    for (RexNode newCall : constExps) {
        LogicalExpression logEx = DrillOptiq.toDrill(new DrillParseContext(plannerSettings), (RelNode) null, /* input rel */
        newCall);
        ErrorCollectorImpl errors = new ErrorCollectorImpl();
        LogicalExpression materializedExpr = ExpressionTreeMaterializer.materialize(logEx, null, errors, funcImplReg);
        if (errors.getErrorCount() != 0) {
            String message = String.format("Failure while materializing expression in constant expression evaluator [%s].  Errors: %s", newCall.toString(), errors.toString());
            throw UserException.planError().message(message).build(logger);
        }
        if (NON_REDUCIBLE_TYPES.contains(materializedExpr.getMajorType().getMinorType())) {
            logger.debug("Constant expression not folded due to return type {}, complete expression: {}", materializedExpr.getMajorType(), ExpressionStringBuilder.toString(materializedExpr));
            reducedValues.add(newCall);
            continue;
        }
        ValueHolder output = InterpreterEvaluator.evaluateConstantExpr(udfUtilities, materializedExpr);
        RelDataTypeFactory typeFactory = rexBuilder.getTypeFactory();
        if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL && TypeHelper.isNull(output)) {
            SqlTypeName sqlTypeName = TypeInferenceUtils.getCalciteTypeFromDrillType(materializedExpr.getMajorType().getMinorType());
            if (sqlTypeName == null) {
                String message = String.format("Error reducing constant expression, unsupported type: %s.", materializedExpr.getMajorType().getMinorType());
                throw UserException.unsupportedError().message(message).build(logger);
            }
            RelDataType type = TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, sqlTypeName, true);
            reducedValues.add(rexBuilder.makeNullLiteral(type));
            continue;
        }
        Function<ValueHolder, RexNode> literator = valueHolder -> {
            switch(materializedExpr.getMajorType().getMinorType()) {
                case INT:
                    {
                        int value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? ((NullableIntHolder) valueHolder).value : ((IntHolder) valueHolder).value;
                        return rexBuilder.makeLiteral(new BigDecimal(value), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.INTEGER, newCall.getType().isNullable()), false);
                    }
                case BIGINT:
                    {
                        long value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? ((NullableBigIntHolder) valueHolder).value : ((BigIntHolder) valueHolder).value;
                        return rexBuilder.makeLiteral(new BigDecimal(value), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.BIGINT, newCall.getType().isNullable()), false);
                    }
                case FLOAT4:
                    {
                        float value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? ((NullableFloat4Holder) valueHolder).value : ((Float4Holder) valueHolder).value;
                        // BigDecimal cannot represent them.
                        if (!Float.isFinite(value)) {
                            return rexBuilder.makeLiteral(Float.toString(value));
                        }
                        return rexBuilder.makeLiteral(new BigDecimal(value), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.FLOAT, newCall.getType().isNullable()), false);
                    }
                case FLOAT8:
                    {
                        double value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? ((NullableFloat8Holder) valueHolder).value : ((Float8Holder) valueHolder).value;
                        // BigDecimal cannot represent them.
                        if (!Double.isFinite(value)) {
                            return rexBuilder.makeLiteral(Double.toString(value));
                        }
                        return rexBuilder.makeLiteral(new BigDecimal(value), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.DOUBLE, newCall.getType().isNullable()), false);
                    }
                case VARCHAR:
                    {
                        String value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? StringFunctionHelpers.getStringFromVarCharHolder((NullableVarCharHolder) valueHolder) : StringFunctionHelpers.getStringFromVarCharHolder((VarCharHolder) valueHolder);
                        RelDataType type = typeFactory.createSqlType(SqlTypeName.VARCHAR, newCall.getType().getPrecision());
                        RelDataType typeWithNullability = typeFactory.createTypeWithNullability(type, newCall.getType().isNullable());
                        return rexBuilder.makeLiteral(value, typeWithNullability, false);
                    }
                case BIT:
                    {
                        boolean value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? ((NullableBitHolder) valueHolder).value == 1 : ((BitHolder) valueHolder).value == 1;
                        return rexBuilder.makeLiteral(value, TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.BOOLEAN, newCall.getType().isNullable()), false);
                    }
                case DATE:
                    {
                        Calendar value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? new DateTime(((NullableDateHolder) valueHolder).value, DateTimeZone.UTC).toCalendar(null) : new DateTime(((DateHolder) valueHolder).value, DateTimeZone.UTC).toCalendar(null);
                        return rexBuilder.makeLiteral(DateString.fromCalendarFields(value), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.DATE, newCall.getType().isNullable()), false);
                    }
                case DECIMAL9:
                    {
                        long value;
                        int scale;
                        if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
                            NullableDecimal9Holder decimal9Out = (NullableDecimal9Holder) valueHolder;
                            value = decimal9Out.value;
                            scale = decimal9Out.scale;
                        } else {
                            Decimal9Holder decimal9Out = (Decimal9Holder) valueHolder;
                            value = decimal9Out.value;
                            scale = decimal9Out.scale;
                        }
                        return rexBuilder.makeLiteral(new BigDecimal(BigInteger.valueOf(value), scale), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.DECIMAL, newCall.getType().isNullable()), false);
                    }
                case DECIMAL18:
                    {
                        long value;
                        int scale;
                        if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
                            NullableDecimal18Holder decimal18Out = (NullableDecimal18Holder) valueHolder;
                            value = decimal18Out.value;
                            scale = decimal18Out.scale;
                        } else {
                            Decimal18Holder decimal18Out = (Decimal18Holder) valueHolder;
                            value = decimal18Out.value;
                            scale = decimal18Out.scale;
                        }
                        return rexBuilder.makeLiteral(new BigDecimal(BigInteger.valueOf(value), scale), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.DECIMAL, newCall.getType().isNullable()), false);
                    }
                case VARDECIMAL:
                    {
                        DrillBuf buffer;
                        int start;
                        int end;
                        int scale;
                        int precision;
                        if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
                            NullableVarDecimalHolder varDecimalHolder = (NullableVarDecimalHolder) valueHolder;
                            buffer = varDecimalHolder.buffer;
                            start = varDecimalHolder.start;
                            end = varDecimalHolder.end;
                            scale = varDecimalHolder.scale;
                            precision = varDecimalHolder.precision;
                        } else {
                            VarDecimalHolder varDecimalHolder = (VarDecimalHolder) valueHolder;
                            buffer = varDecimalHolder.buffer;
                            start = varDecimalHolder.start;
                            end = varDecimalHolder.end;
                            scale = varDecimalHolder.scale;
                            precision = varDecimalHolder.precision;
                        }
                        return rexBuilder.makeLiteral(org.apache.drill.exec.util.DecimalUtility.getBigDecimalFromDrillBuf(buffer, start, end - start, scale), typeFactory.createSqlType(SqlTypeName.DECIMAL, precision, scale), false);
                    }
                case DECIMAL28SPARSE:
                    {
                        DrillBuf buffer;
                        int start;
                        int scale;
                        if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
                            NullableDecimal28SparseHolder decimal28Out = (NullableDecimal28SparseHolder) valueHolder;
                            buffer = decimal28Out.buffer;
                            start = decimal28Out.start;
                            scale = decimal28Out.scale;
                        } else {
                            Decimal28SparseHolder decimal28Out = (Decimal28SparseHolder) valueHolder;
                            buffer = decimal28Out.buffer;
                            start = decimal28Out.start;
                            scale = decimal28Out.scale;
                        }
                        return rexBuilder.makeLiteral(org.apache.drill.exec.util.DecimalUtility.getBigDecimalFromSparse(buffer, start * 20, 5, scale), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.DECIMAL, newCall.getType().isNullable()), false);
                    }
                case DECIMAL38SPARSE:
                    {
                        DrillBuf buffer;
                        int start;
                        int scale;
                        if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
                            NullableDecimal38SparseHolder decimal38Out = (NullableDecimal38SparseHolder) valueHolder;
                            buffer = decimal38Out.buffer;
                            start = decimal38Out.start;
                            scale = decimal38Out.scale;
                        } else {
                            Decimal38SparseHolder decimal38Out = (Decimal38SparseHolder) valueHolder;
                            buffer = decimal38Out.buffer;
                            start = decimal38Out.start;
                            scale = decimal38Out.scale;
                        }
                        return rexBuilder.makeLiteral(org.apache.drill.exec.util.DecimalUtility.getBigDecimalFromSparse(buffer, start * 24, 6, scale), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.DECIMAL, newCall.getType().isNullable()), false);
                    }
                case TIME:
                    {
                        Calendar value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? new DateTime(((NullableTimeHolder) valueHolder).value, DateTimeZone.UTC).toCalendar(null) : new DateTime(((TimeHolder) valueHolder).value, DateTimeZone.UTC).toCalendar(null);
                        RelDataType type = typeFactory.createSqlType(SqlTypeName.TIME, newCall.getType().getPrecision());
                        RelDataType typeWithNullability = typeFactory.createTypeWithNullability(type, newCall.getType().isNullable());
                        return rexBuilder.makeLiteral(TimeString.fromCalendarFields(value), typeWithNullability, false);
                    }
                case TIMESTAMP:
                    {
                        Calendar value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? new DateTime(((NullableTimeStampHolder) valueHolder).value, DateTimeZone.UTC).toCalendar(null) : new DateTime(((TimeStampHolder) valueHolder).value, DateTimeZone.UTC).toCalendar(null);
                        RelDataType type = typeFactory.createSqlType(SqlTypeName.TIMESTAMP, newCall.getType().getPrecision());
                        RelDataType typeWithNullability = typeFactory.createTypeWithNullability(type, newCall.getType().isNullable());
                        return rexBuilder.makeLiteral(TimestampString.fromCalendarFields(value), typeWithNullability, false);
                    }
                case INTERVALYEAR:
                    {
                        BigDecimal value = (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) ? new BigDecimal(((NullableIntervalYearHolder) valueHolder).value) : new BigDecimal(((IntervalYearHolder) valueHolder).value);
                        return rexBuilder.makeLiteral(value, TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.INTERVAL_YEAR_MONTH, newCall.getType().isNullable()), false);
                    }
                case INTERVALDAY:
                    {
                        int days;
                        int milliseconds;
                        if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
                            NullableIntervalDayHolder intervalDayOut = (NullableIntervalDayHolder) valueHolder;
                            days = intervalDayOut.days;
                            milliseconds = intervalDayOut.milliseconds;
                        } else {
                            IntervalDayHolder intervalDayOut = (IntervalDayHolder) valueHolder;
                            days = intervalDayOut.days;
                            milliseconds = intervalDayOut.milliseconds;
                        }
                        return rexBuilder.makeLiteral(new BigDecimal(days * (long) DateUtilities.daysToStandardMillis + milliseconds), TypeInferenceUtils.createCalciteTypeWithNullability(typeFactory, SqlTypeName.INTERVAL_DAY, newCall.getType().isNullable()), false);
                    }
                // as new types may be added in the future.
                default:
                    logger.debug("Constant expression not folded due to return type {}, complete expression: {}", materializedExpr.getMajorType(), ExpressionStringBuilder.toString(materializedExpr));
                    return newCall;
            }
        };
        reducedValues.add(literator.apply(output));
    }
}
Also used : RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) DateTimeZone(org.joda.time.DateTimeZone) VarDecimalHolder(org.apache.drill.exec.expr.holders.VarDecimalHolder) ExpressionTreeMaterializer(org.apache.drill.exec.expr.ExpressionTreeMaterializer) UserException(org.apache.drill.common.exceptions.UserException) TypeHelper(org.apache.drill.exec.expr.TypeHelper) VarCharHolder(org.apache.drill.exec.expr.holders.VarCharHolder) StringFunctionHelpers(org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers) NullableVarCharHolder(org.apache.drill.exec.expr.holders.NullableVarCharHolder) NullableVarDecimalHolder(org.apache.drill.exec.expr.holders.NullableVarDecimalHolder) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) ExpressionStringBuilder(org.apache.drill.common.expression.ExpressionStringBuilder) NullableIntervalDayHolder(org.apache.drill.exec.expr.holders.NullableIntervalDayHolder) BigDecimal(java.math.BigDecimal) UdfUtilities(org.apache.drill.exec.ops.UdfUtilities) RexNode(org.apache.calcite.rex.RexNode) Decimal9Holder(org.apache.drill.exec.expr.holders.Decimal9Holder) DateHolder(org.apache.drill.exec.expr.holders.DateHolder) NullableIntervalYearHolder(org.apache.drill.exec.expr.holders.NullableIntervalYearHolder) DrillBuf(io.netty.buffer.DrillBuf) BigIntHolder(org.apache.drill.exec.expr.holders.BigIntHolder) BigInteger(java.math.BigInteger) NullableBigIntHolder(org.apache.drill.exec.expr.holders.NullableBigIntHolder) NullableDecimal9Holder(org.apache.drill.exec.expr.holders.NullableDecimal9Holder) Decimal18Holder(org.apache.drill.exec.expr.holders.Decimal18Holder) DateString(org.apache.calcite.util.DateString) Decimal28SparseHolder(org.apache.drill.exec.expr.holders.Decimal28SparseHolder) NullableFloat4Holder(org.apache.drill.exec.expr.holders.NullableFloat4Holder) TimestampString(org.apache.calcite.util.TimestampString) ErrorCollectorImpl(org.apache.drill.common.expression.ErrorCollectorImpl) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) TypeProtos(org.apache.drill.common.types.TypeProtos) List(java.util.List) NullableTimeStampHolder(org.apache.drill.exec.expr.holders.NullableTimeStampHolder) ValueHolder(org.apache.drill.exec.expr.holders.ValueHolder) Decimal38SparseHolder(org.apache.drill.exec.expr.holders.Decimal38SparseHolder) BitHolder(org.apache.drill.exec.expr.holders.BitHolder) NullableFloat8Holder(org.apache.drill.exec.expr.holders.NullableFloat8Holder) IntervalYearHolder(org.apache.drill.exec.expr.holders.IntervalYearHolder) Float8Holder(org.apache.drill.exec.expr.holders.Float8Holder) Function(java.util.function.Function) Float4Holder(org.apache.drill.exec.expr.holders.Float4Holder) TimeString(org.apache.calcite.util.TimeString) Calendar(java.util.Calendar) InterpreterEvaluator(org.apache.drill.exec.expr.fn.interpreter.InterpreterEvaluator) TimeHolder(org.apache.drill.exec.expr.holders.TimeHolder) NullableBitHolder(org.apache.drill.exec.expr.holders.NullableBitHolder) IntHolder(org.apache.drill.exec.expr.holders.IntHolder) RexExecutor(org.apache.calcite.rex.RexExecutor) RelDataType(org.apache.calcite.rel.type.RelDataType) NullableDecimal18Holder(org.apache.drill.exec.expr.holders.NullableDecimal18Holder) DateUtilities(org.apache.drill.exec.vector.DateUtilities) NullableDecimal38SparseHolder(org.apache.drill.exec.expr.holders.NullableDecimal38SparseHolder) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) NullableDecimal28SparseHolder(org.apache.drill.exec.expr.holders.NullableDecimal28SparseHolder) TypeInferenceUtils(org.apache.drill.exec.planner.sql.TypeInferenceUtils) RexBuilder(org.apache.calcite.rex.RexBuilder) DateTime(org.joda.time.DateTime) RelNode(org.apache.calcite.rel.RelNode) NullableTimeHolder(org.apache.drill.exec.expr.holders.NullableTimeHolder) ImmutableList(org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList) IntervalDayHolder(org.apache.drill.exec.expr.holders.IntervalDayHolder) NullableIntHolder(org.apache.drill.exec.expr.holders.NullableIntHolder) PlannerSettings(org.apache.drill.exec.planner.physical.PlannerSettings) TimeStampHolder(org.apache.drill.exec.expr.holders.TimeStampHolder) NullableDateHolder(org.apache.drill.exec.expr.holders.NullableDateHolder) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) NullableDecimal9Holder(org.apache.drill.exec.expr.holders.NullableDecimal9Holder) BitHolder(org.apache.drill.exec.expr.holders.BitHolder) NullableBitHolder(org.apache.drill.exec.expr.holders.NullableBitHolder) NullableVarDecimalHolder(org.apache.drill.exec.expr.holders.NullableVarDecimalHolder) Decimal9Holder(org.apache.drill.exec.expr.holders.Decimal9Holder) NullableDecimal9Holder(org.apache.drill.exec.expr.holders.NullableDecimal9Holder) VarDecimalHolder(org.apache.drill.exec.expr.holders.VarDecimalHolder) NullableVarDecimalHolder(org.apache.drill.exec.expr.holders.NullableVarDecimalHolder) RelDataType(org.apache.calcite.rel.type.RelDataType) DateString(org.apache.calcite.util.DateString) TimestampString(org.apache.calcite.util.TimestampString) TimeString(org.apache.calcite.util.TimeString) DateTime(org.joda.time.DateTime) NullableIntervalYearHolder(org.apache.drill.exec.expr.holders.NullableIntervalYearHolder) IntervalYearHolder(org.apache.drill.exec.expr.holders.IntervalYearHolder) ErrorCollectorImpl(org.apache.drill.common.expression.ErrorCollectorImpl) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) NullableVarCharHolder(org.apache.drill.exec.expr.holders.NullableVarCharHolder) NullableIntervalYearHolder(org.apache.drill.exec.expr.holders.NullableIntervalYearHolder) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) DrillBuf(io.netty.buffer.DrillBuf) NullableIntervalDayHolder(org.apache.drill.exec.expr.holders.NullableIntervalDayHolder) Decimal18Holder(org.apache.drill.exec.expr.holders.Decimal18Holder) NullableDecimal18Holder(org.apache.drill.exec.expr.holders.NullableDecimal18Holder) NullableIntervalDayHolder(org.apache.drill.exec.expr.holders.NullableIntervalDayHolder) IntervalDayHolder(org.apache.drill.exec.expr.holders.IntervalDayHolder) Calendar(java.util.Calendar) NullableDecimal38SparseHolder(org.apache.drill.exec.expr.holders.NullableDecimal38SparseHolder) ValueHolder(org.apache.drill.exec.expr.holders.ValueHolder) BigDecimal(java.math.BigDecimal) NullableDecimal28SparseHolder(org.apache.drill.exec.expr.holders.NullableDecimal28SparseHolder) NullableDecimal18Holder(org.apache.drill.exec.expr.holders.NullableDecimal18Holder) NullableBitHolder(org.apache.drill.exec.expr.holders.NullableBitHolder) Decimal38SparseHolder(org.apache.drill.exec.expr.holders.Decimal38SparseHolder) NullableDecimal38SparseHolder(org.apache.drill.exec.expr.holders.NullableDecimal38SparseHolder) Decimal28SparseHolder(org.apache.drill.exec.expr.holders.Decimal28SparseHolder) NullableDecimal28SparseHolder(org.apache.drill.exec.expr.holders.NullableDecimal28SparseHolder) VarCharHolder(org.apache.drill.exec.expr.holders.VarCharHolder) NullableVarCharHolder(org.apache.drill.exec.expr.holders.NullableVarCharHolder) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)78 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)78 ErrorCollector (org.apache.drill.common.expression.ErrorCollector)74 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)36 HoldingContainer (org.apache.drill.exec.expr.ClassGenerator.HoldingContainer)25 Ordering (org.apache.drill.common.logical.data.Order.Ordering)23 TypedFieldId (org.apache.drill.exec.record.TypedFieldId)22 JConditional (com.sun.codemodel.JConditional)21 MaterializedField (org.apache.drill.exec.record.MaterializedField)19 ValueVector (org.apache.drill.exec.vector.ValueVector)18 SchemaPath (org.apache.drill.common.expression.SchemaPath)13 ValueVectorWriteExpression (org.apache.drill.exec.expr.ValueVectorWriteExpression)13 TransferPair (org.apache.drill.exec.record.TransferPair)13 IOException (java.io.IOException)11 NamedExpression (org.apache.drill.common.logical.data.NamedExpression)11 FieldReference (org.apache.drill.common.expression.FieldReference)10 ExecTest (org.apache.drill.exec.ExecTest)9 Test (org.junit.Test)9 ClassTransformationException (org.apache.drill.exec.exception.ClassTransformationException)8 IfExpression (org.apache.drill.common.expression.IfExpression)7