Search in sources :

Example 16 with Statement

use of com.thinkbiganalytics.kylo.spark.model.Statement in project kylo by Teradata.

the class TestLivyRestModelTransformer method simpleTestWithSchema.

@Test
public void simpleTestWithSchema() throws IOException {
    final String json = TestUtils.getTestResourcesFileAsString("dataFrameStatementPostResponseWithSchema.json");
    // JSON from String to Object
    Statement statement = new ObjectMapper().readValue(json, Statement.class);
    logger.info("response={}", statement);
    TransformResponse response = LivyRestModelTransformer.toTransformResponse(statement, "testTableName");
    assertThat(response).hasFieldOrPropertyWithValue("status", TransformResponse.Status.SUCCESS);
    assertThat(response).hasFieldOrPropertyWithValue("progress", 1.0);
    TransformQueryResult tqr = response.getResults();
    assertThat(tqr).isNotNull();
    List<QueryResultColumn> cols = tqr.getColumns();
    assertThat(cols).isNotNull();
    QueryResultColumn dt0 = cols.get(0);
    assertThat(dt0).hasFieldOrPropertyWithValue("dataType", "integer");
    List<Object> row1 = Lists.newArrayList(1, "Toyota Park", "Bridgeview", "IL", 0, "1527526048390");
    assertThat(tqr.getRows()).contains(row1);
}
Also used : Statement(com.thinkbiganalytics.kylo.spark.model.Statement) TransformQueryResult(com.thinkbiganalytics.spark.rest.model.TransformQueryResult) TransformResponse(com.thinkbiganalytics.spark.rest.model.TransformResponse) QueryResultColumn(com.thinkbiganalytics.discovery.schema.QueryResultColumn) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

Statement (com.thinkbiganalytics.kylo.spark.model.Statement)16 JerseyRestClient (com.thinkbiganalytics.rest.JerseyRestClient)11 Nonnull (javax.annotation.Nonnull)9 LivyUserException (com.thinkbiganalytics.kylo.spark.exceptions.LivyUserException)6 SparkJobResponse (com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse)4 SaveResponse (com.thinkbiganalytics.spark.rest.model.SaveResponse)4 TransformResponse (com.thinkbiganalytics.spark.rest.model.TransformResponse)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 QueryResultColumn (com.thinkbiganalytics.discovery.schema.QueryResultColumn)2 LivyCodeException (com.thinkbiganalytics.kylo.spark.exceptions.LivyCodeException)2 LivyException (com.thinkbiganalytics.kylo.spark.exceptions.LivyException)2 ServerStatusResponse (com.thinkbiganalytics.spark.rest.model.ServerStatusResponse)2 TransformQueryResult (com.thinkbiganalytics.spark.rest.model.TransformQueryResult)2 URI (java.net.URI)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Cache (com.google.common.cache.Cache)1