Search in sources :

Example 16 with QueryResults

use of com.facebook.presto.client.QueryResults in project presto by prestodb.

the class TestServer method testInvalidSessionError.

@Test
public void testInvalidSessionError() throws Exception {
    String invalidTimeZone = "this_is_an_invalid_time_zone";
    Request request = preparePost().setHeader(PRESTO_USER, "user").setUri(uriFor("/v1/statement")).setBodyGenerator(createStaticBodyGenerator("show catalogs", UTF_8)).setHeader(PRESTO_SOURCE, "source").setHeader(PRESTO_CATALOG, "catalog").setHeader(PRESTO_SCHEMA, "schema").setHeader(PRESTO_TIME_ZONE, invalidTimeZone).build();
    QueryResults queryResults = client.execute(request, createJsonResponseHandler(jsonCodec(QueryResults.class)));
    QueryError queryError = queryResults.getError();
    assertNotNull(queryError);
    TimeZoneNotSupportedException expected = new TimeZoneNotSupportedException(invalidTimeZone);
    assertEquals(queryError.getErrorCode(), expected.getErrorCode().getCode());
    assertEquals(queryError.getErrorName(), expected.getErrorCode().getName());
    assertEquals(queryError.getErrorType(), expected.getErrorCode().getType().name());
    assertEquals(queryError.getMessage(), expected.getMessage());
}
Also used : Request(io.airlift.http.client.Request) QueryError(com.facebook.presto.client.QueryError) TimeZoneNotSupportedException(com.facebook.presto.spi.type.TimeZoneNotSupportedException) QueryResults(com.facebook.presto.client.QueryResults) Test(org.testng.annotations.Test)

Aggregations

QueryResults (com.facebook.presto.client.QueryResults)16 StatementClient (com.facebook.presto.client.StatementClient)7 ImmutableList (com.google.common.collect.ImmutableList)7 List (java.util.List)7 Nullable (javax.annotation.Nullable)5 QueryClient (com.airbnb.airpal.core.execution.QueryClient)4 QueryRunner (com.airbnb.airpal.presto.QueryRunner)4 QueryError (com.facebook.presto.client.QueryError)4 Request (io.airlift.http.client.Request)4 Test (org.testng.annotations.Test)4 Column (com.facebook.presto.client.Column)3 HiveColumn (com.airbnb.airpal.presto.hive.HiveColumn)2 Duration (io.airlift.units.Duration)2 JobState (com.airbnb.airpal.api.JobState)1 InvalidQueryException (com.airbnb.airpal.api.output.InvalidQueryException)1 FileTooLargeException (com.airbnb.airpal.api.output.builders.FileTooLargeException)1 JobOutputBuilder (com.airbnb.airpal.api.output.builders.JobOutputBuilder)1 Persistor (com.airbnb.airpal.api.output.persistors.Persistor)1 ExecutionFailureException (com.airbnb.airpal.core.execution.ExecutionClient.ExecutionFailureException)1 QueryTimeOutException (com.airbnb.airpal.core.execution.QueryClient.QueryTimeOutException)1