use of com.thinkbiganalytics.spark.rest.model.TransformQueryResult in project kylo by Teradata.
the class ResponseStage method apply.
@Nonnull
@Override
public TransformResponse apply(@Nullable final TransformResult result) {
Preconditions.checkNotNull(result);
// Transform data set into rows
final QueryResultRowTransform rowTransform = new QueryResultRowTransform(result.getDataSet().schema(), table);
final List<List<Object>> rows = Lists.transform(result.getDataSet().collectAsList(), new Function<Row, List<Object>>() {
@Nullable
@Override
public List<Object> apply(@Nullable Row row) {
return (row != null) ? rowTransform.convertRow(row) : null;
}
});
// Build the query result
final TransformQueryResult queryResult = new TransformQueryResult();
queryResult.setColumns(result.getColumns());
queryResult.setRows(rows);
queryResult.setValidationResults(result.getValidationResults());
// Build the response
final TransformResponse response = new TransformResponse();
response.setProfile(result.getProfile());
response.setResults(queryResult);
response.setStatus(TransformResponse.Status.SUCCESS);
response.setTable(table);
return response;
}
use of com.thinkbiganalytics.spark.rest.model.TransformQueryResult in project kylo by Teradata.
the class TransformService method execute.
/**
* Executes the specified transformation and returns the name of the Hive table containing the results.
*
* @param request the transformation request
* @return the Hive table containing the results
* @throws IllegalStateException if this service is not running
* @throws ScriptException if the script cannot be executed
*/
@Nonnull
public TransformResponse execute(@Nonnull final TransformRequest request) throws ScriptException {
log.entry(request);
// Handle async request
if (request.isAsync()) {
return cacheTransform(request);
}
// Execute script
final DataSet dataSet = createShellTask(request);
final StructType schema = dataSet.schema();
TransformResponse response = submitTransformJob(new ShellTransformStage(dataSet), getPolicies(request));
// Build response
if (response.getStatus() != TransformResponse.Status.SUCCESS) {
final String table = response.getTable();
final TransformQueryResult partialResult = new TransformQueryResult();
partialResult.setColumns(Arrays.<QueryResultColumn>asList(new QueryResultRowTransform(schema, table).columns()));
response = new TransformResponse();
response.setProgress(0.0);
response.setResults(partialResult);
response.setStatus(TransformResponse.Status.PENDING);
response.setTable(table);
}
return log.exit(response);
}
use of com.thinkbiganalytics.spark.rest.model.TransformQueryResult 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;
}
Aggregations