Search in sources :

Example 6 with Float4Holder

use of org.apache.drill.exec.expr.holders.Float4Holder in project drill by axbaretto.

the class ValueHolderHelper method getFloat4Holder.

public static Float4Holder getFloat4Holder(float value) {
    Float4Holder holder = new Float4Holder();
    holder.value = value;
    return holder;
}
Also used : Float4Holder(org.apache.drill.exec.expr.holders.Float4Holder)

Example 7 with Float4Holder

use of org.apache.drill.exec.expr.holders.Float4Holder in project drill by apache.

the class TestCastFunctions method testCastFloat4.

@Test
public // cast to float4
void testCastFloat4() throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(CONFIG);
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/functions/cast/testCastFloat4.json"), Charsets.UTF_8).read());
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(CONFIG);
    final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
    while (exec.next()) {
        final Float4Vector c0 = exec.getValueVectorById(new SchemaPath("varchar_cast2", ExpressionPosition.UNKNOWN), Float4Vector.class);
        final Float4Vector.Accessor a0 = c0.getAccessor();
        int count = 0;
        for (int i = 0; i < c0.getAccessor().getValueCount(); i++) {
            final Float4Holder holder0 = new Float4Holder();
            a0.get(i, holder0);
            assertEquals(12.56, holder0.value, 0.001);
            ++count;
        }
        assertEquals(5, count);
    }
    exec.close();
    context.close();
    if (context.getExecutorState().getFailureCause() != null) {
        throw context.getExecutorState().getFailureCause();
    }
    assertTrue(!context.getExecutorState().isFailed());
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) Float4Vector(org.apache.drill.exec.vector.Float4Vector) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) Float4Holder(org.apache.drill.exec.expr.holders.Float4Holder) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) SchemaPath(org.apache.drill.common.expression.SchemaPath) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) Test(org.junit.Test)

Aggregations

Float4Holder (org.apache.drill.exec.expr.holders.Float4Holder)7 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)4 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 DrillBuf (io.netty.buffer.DrillBuf)2 BigDecimal (java.math.BigDecimal)2 Calendar (java.util.Calendar)2 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)2 RexNode (org.apache.calcite.rex.RexNode)2 SqlTypeName (org.apache.calcite.sql.type.SqlTypeName)2 DateString (org.apache.calcite.util.DateString)2 TimeString (org.apache.calcite.util.TimeString)2 TimestampString (org.apache.calcite.util.TimestampString)2 ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2 BigIntHolder (org.apache.drill.exec.expr.holders.BigIntHolder)2 DateHolder (org.apache.drill.exec.expr.holders.DateHolder)2 Decimal18Holder (org.apache.drill.exec.expr.holders.Decimal18Holder)2 Decimal28SparseHolder (org.apache.drill.exec.expr.holders.Decimal28SparseHolder)2 Decimal38SparseHolder (org.apache.drill.exec.expr.holders.Decimal38SparseHolder)2 Decimal9Holder (org.apache.drill.exec.expr.holders.Decimal9Holder)2