Search in sources :

Example 6 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.

the class TestUserException method testBuildUserExceptionWithCause.

@Test
public void testBuildUserExceptionWithCause() {
    String message = "Test message";
    UserException uex = UserException.dataWriteError(new RuntimeException(message)).build(logger);
    DrillPBError error = uex.getOrCreatePBError(false);
    // cause message should be used
    Assert.assertEquals(ErrorType.DATA_WRITE, error.getErrorType());
    Assert.assertEquals(message, uex.getOriginalMessage());
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Example 7 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.

the class PlanSplitter method planFragments.

/**
   * Method to plan the query and return list of fragments
   * it will return query plan "as is" or split plans based on the req setting: split_plan
   * @param dContext
   * @param queryId
   * @param req
   * @param connection
   * @return
   */
public QueryPlanFragments planFragments(DrillbitContext dContext, QueryId queryId, GetQueryPlanFragments req, UserClientConnection connection) {
    QueryPlanFragments.Builder responseBuilder = QueryPlanFragments.newBuilder();
    QueryContext queryContext = new QueryContext(connection.getSession(), dContext, queryId);
    responseBuilder.setQueryId(queryId);
    try {
        responseBuilder.addAllFragments(getFragments(dContext, req, queryContext, queryId));
        responseBuilder.setStatus(QueryState.COMPLETED);
    } catch (Exception e) {
        final String errorMessage = String.format("Failed to produce PlanFragments for query id \"%s\" with " + "request to %s plan", queryId, (req.getSplitPlan() ? "split" : "no split"));
        DrillPBError error = DrillPBError.newBuilder().setMessage(errorMessage).setErrorType(DrillPBError.ErrorType.PLAN).build();
        responseBuilder.setStatus(QueryState.FAILED);
        responseBuilder.setError(error);
    }
    return responseBuilder.build();
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) GetQueryPlanFragments(org.apache.drill.exec.proto.UserProtos.GetQueryPlanFragments) QueryContext(org.apache.drill.exec.ops.QueryContext)

Example 8 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.

the class TestUserException method testBuildUserExceptionWithUserExceptionCauseAndMessage.

@Test
public void testBuildUserExceptionWithUserExceptionCauseAndMessage() {
    String messageA = "Test message A";
    String messageB = "Test message B";
    UserException original = UserException.connectionError().message(messageA).build(logger);
    UserException uex = UserException.dataWriteError(wrap(original, 5)).message(messageB).build(logger);
    //builder should return the unwrapped original user exception and not build a new one
    Assert.assertEquals(original, uex);
    DrillPBError error = uex.getOrCreatePBError(false);
    Assert.assertEquals(messageA, uex.getOriginalMessage());
    // messageB should not be part of the context
    Assert.assertFalse(error.getMessage().contains(messageB));
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Example 9 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.

the class TestUserException method testBuildSystemException.

// make sure system exceptions are created properly
@Test
public void testBuildSystemException() {
    String message = "This is an exception";
    UserException uex = UserException.systemError(new Exception(new RuntimeException(message))).build(logger);
    Assert.assertTrue(uex.getOriginalMessage().contains(message));
    Assert.assertTrue(uex.getOriginalMessage().contains("RuntimeException"));
    DrillPBError error = uex.getOrCreatePBError(true);
    Assert.assertEquals(ErrorType.SYSTEM, error.getErrorType());
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Example 10 with DrillPBError

use of org.apache.drill.exec.proto.UserBitShared.DrillPBError in project drill by apache.

the class TestUserException method testBuildUserExceptionWithFormattedMessage.

@Test
public void testBuildUserExceptionWithFormattedMessage() {
    String format = "This is test #%d";
    UserException uex = UserException.connectionError().message(format, 5).build(logger);
    DrillPBError error = uex.getOrCreatePBError(false);
    Assert.assertEquals(ErrorType.CONNECTION, error.getErrorType());
    Assert.assertEquals(String.format(format, 5), uex.getOriginalMessage());
}
Also used : DrillPBError(org.apache.drill.exec.proto.UserBitShared.DrillPBError) Test(org.junit.Test)

Aggregations

DrillPBError (org.apache.drill.exec.proto.UserBitShared.DrillPBError)12 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 LikeFilter (org.apache.drill.exec.proto.UserProtos.LikeFilter)3 RequestStatus (org.apache.drill.exec.proto.UserProtos.RequestStatus)3 MetaImpl (org.apache.calcite.avatica.MetaImpl)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 SingleRowListener (org.apache.drill.SingleRowListener)1 UserException (org.apache.drill.common.exceptions.UserException)1 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)1 DrillbitStartupException (org.apache.drill.exec.exception.DrillbitStartupException)1 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)1 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)1 QueryContext (org.apache.drill.exec.ops.QueryContext)1 QueryData (org.apache.drill.exec.proto.UserBitShared.QueryData)1 QueryState (org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState)1 ColumnMetadata (org.apache.drill.exec.proto.UserProtos.ColumnMetadata)1