use of com.thinkbiganalytics.spark.rest.model.TransformResponse in project kylo by Teradata.
the class SparkFileSchemaParserServiceTest method transformResponse.
private TransformResponse transformResponse(List<QueryResultColumn> columns) {
TransformResponse transformResponse = new TransformResponse();
transformResponse.setStatus(TransformResponse.Status.SUCCESS);
TransformQueryResult result = new TransformQueryResult();
result.setColumns(columns);
transformResponse.setResults(result);
return transformResponse;
}
use of com.thinkbiganalytics.spark.rest.model.TransformResponse in project kylo by Teradata.
the class SparkShellIT method testScriptSave.
/**
* Verify saving the result of a script.
*/
@Test
public void testScriptSave() {
final TransformResponse transform = executeScript(SCRIPT, true);
final String tableName = newTableName();
final SaveResponse save = saveScript(transform.getTable(), "orc", null, tableName);
Assert.assertEquals(SaveResponse.Status.SUCCESS, save.getStatus());
try {
final List<HashMap<String, String>> table = getHiveQuery("SELECT * FROM " + tableName);
Assert.assertEquals(ImmutableList.of(ImmutableMap.of("id", 1, "value", "a"), ImmutableMap.of("id", 2, "value", "b"), ImmutableMap.of("id", 3, "value", "c")), table);
} finally {
ssh("hive -e \"drop table " + tableName + "\"");
}
}
use of com.thinkbiganalytics.spark.rest.model.TransformResponse in project kylo by Teradata.
the class SparkShellProxyController method transformError.
/**
* Generates an error response for a failed transform.
*
* <p>Example:
* <code>
* throw transformError(Response.Status.BAD_REQUEST, "transform.error", e);
* </code></p>
*
* @param status HTTP response status
* @param key resource key or error message
* @param cause the cause
* @return the error response
*/
@Nonnull
private WebApplicationException transformError(@Nonnull final Response.Status status, @Nonnull final String key, @Nullable final Throwable cause) {
// Create entity
final TransformResponse entity = new TransformResponse();
entity.setStatus(TransformResponse.Status.ERROR);
try {
entity.setMessage(STRINGS.getString(key));
} catch (final MissingResourceException e) {
log.warn("Missing resource message: {}", key, e);
entity.setMessage(key);
}
// Generate the response
final Response response = Response.status(status).entity(entity).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
if (cause != null) {
return new WebApplicationException(cause, response);
} else {
return new WebApplicationException(response);
}
}
Aggregations