Search in sources :

Example 21 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by axbaretto.

the class TestMergeJoin method orderedEqualityMultiBatchJoin.

@Test
@Ignore
public void orderedEqualityMultiBatchJoin() throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c, new StoragePluginRegistryImpl(bitContext));
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.json"), Charsets.UTF_8).replace("#{LEFT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.left.json").toURI().toString()).replace("#{RIGHT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_multi_batch.right.json").toURI().toString()));
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
    final FragmentContextImpl context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
    int totalRecordCount = 0;
    while (exec.next()) {
        totalRecordCount += exec.getRecordCount();
        System.out.println("got next with record count: " + exec.getRecordCount() + " (total: " + totalRecordCount + "):");
        for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) {
            final List<Object> row = Lists.newArrayList();
            for (final ValueVector v : exec) {
                row.add(v.getField().getName() + ":" + v.getAccessor().getObject(valueIdx));
            }
            for (final Object cell : row) {
                if (cell == null) {
                    System.out.print("<null>    ");
                    continue;
                }
                int len = cell.toString().length();
                System.out.print(cell + " ");
                for (int i = 0; i < (10 - len); ++i) {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
    System.out.println("Total Record Count: " + totalRecordCount);
    assertEquals(25, totalRecordCount);
    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) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) ValueVector(org.apache.drill.exec.vector.ValueVector) SimpleRootExec(org.apache.drill.exec.physical.impl.SimpleRootExec) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) Ignore(org.junit.Ignore) SlowTest(org.apache.drill.categories.SlowTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 22 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by axbaretto.

the class TestSimpleLimit method testLimitAcrossBatches.

@Test
@Ignore
public // depending on the size of each outgoing batch, and when the batch could not hold any more values.
void testLimitAcrossBatches() throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    verifyLimitCount(bitContext, connection, "test2.json", 69999);
    final long start = 30000;
    final long end = 100000;
    // Formula for sum of series
    final long expectedSum = (end - start) * (end + start - 1) / 2;
    verifySum(bitContext, connection, "test4.json", 70000, expectedSum);
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) Ignore(org.junit.Ignore) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest)

Example 23 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by axbaretto.

the class TestSimpleLimit method testLimitNoEnd.

@Test
public void testLimitNoEnd() throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    verifyLimitCount(bitContext, connection, "test3.json", 95);
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest)

Example 24 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by axbaretto.

the class TestSimpleProjection method project.

@Test
public void project() throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    final PhysicalPlanReader reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
    final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/project/test1.json"), Charsets.UTF_8));
    final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
    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()) {
        VectorUtil.showVectorAccessibleContent(exec.getIncoming(), "\t");
        final NullableBigIntVector c1 = exec.getValueVectorById(new SchemaPath("col1", ExpressionPosition.UNKNOWN), NullableBigIntVector.class);
        final NullableBigIntVector c2 = exec.getValueVectorById(new SchemaPath("col2", ExpressionPosition.UNKNOWN), NullableBigIntVector.class);
        final NullableBigIntVector.Accessor a1 = c1.getAccessor();
        final NullableBigIntVector.Accessor a2 = c2.getAccessor();
        for (int i = 0; i < c1.getAccessor().getValueCount(); i++) {
            if (!a1.isNull(i)) {
                assertEquals(a1.get(i) + 1, a2.get(i));
            }
        }
    }
    if (context.getExecutorState().getFailureCause() != null) {
        throw context.getExecutorState().getFailureCause();
    }
    assertTrue(!context.getExecutorState().isFailed());
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) SimpleRootExec(org.apache.drill.exec.physical.impl.SimpleRootExec) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) NullableBigIntVector(org.apache.drill.exec.vector.NullableBigIntVector) SchemaPath(org.apache.drill.common.expression.SchemaPath) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) ExecTest(org.apache.drill.exec.ExecTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 25 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by axbaretto.

the class TestNewMathFunctions method runTest.

public void runTest(Object[] expectedResults, String planPath) throws Throwable {
    final DrillbitContext bitContext = mockDrillbitContext();
    final UserClientConnection connection = Mockito.mock(UserClientConnection.class);
    final String planString = Resources.toString(Resources.getResource(planPath), Charsets.UTF_8);
    if (reader == null) {
        reader = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(c);
    }
    if (registry == null) {
        registry = new FunctionImplementationRegistry(c);
    }
    if (context == null) {
        context = new FragmentContextImpl(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
    }
    final PhysicalPlan plan = reader.readPhysicalPlan(planString);
    final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
    // skip schema batch
    exec.next();
    while (exec.next()) {
        final Object[] res = getRunResult(exec);
        assertEquals("return count does not match", expectedResults.length, res.length);
        for (int i = 0; i < res.length; i++) {
            assertEquals(String.format("column %s does not match", i), res[i], expectedResults[i]);
        }
    }
    if (context.getExecutorState().getFailureCause() != null) {
        throw context.getExecutorState().getFailureCause();
    }
    assertTrue(!context.getExecutorState().isFailed());
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) SimpleRootExec(org.apache.drill.exec.physical.impl.SimpleRootExec) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) UserClientConnection(org.apache.drill.exec.rpc.UserClientConnection) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Aggregations

DrillbitContext (org.apache.drill.exec.server.DrillbitContext)137 Test (org.junit.Test)96 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)86 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)80 UserClientConnection (org.apache.drill.exec.rpc.UserClientConnection)78 FragmentContextImpl (org.apache.drill.exec.ops.FragmentContextImpl)77 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)72 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)72 SimpleRootExec (org.apache.drill.exec.physical.impl.SimpleRootExec)44 OperatorTest (org.apache.drill.categories.OperatorTest)39 ExecTest (org.apache.drill.exec.ExecTest)35 SchemaPath (org.apache.drill.common.expression.SchemaPath)32 DrillConfig (org.apache.drill.common.config.DrillConfig)28 ValueVector (org.apache.drill.exec.vector.ValueVector)17 Ignore (org.junit.Ignore)14 IntVector (org.apache.drill.exec.vector.IntVector)13 SecurityTest (org.apache.drill.categories.SecurityTest)12 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)12 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)12 SystemOptionManager (org.apache.drill.exec.server.options.SystemOptionManager)12