Search in sources :

Example 1 with QueryResultRowTransform

use of com.thinkbiganalytics.spark.metadata.QueryResultRowTransform 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);
}
Also used : QueryResultRowTransform(com.thinkbiganalytics.spark.metadata.QueryResultRowTransform) StructType(org.apache.spark.sql.types.StructType) DataSet(com.thinkbiganalytics.spark.DataSet) ShellTransformStage(com.thinkbiganalytics.spark.metadata.ShellTransformStage) TransformQueryResult(com.thinkbiganalytics.spark.rest.model.TransformQueryResult) TransformResponse(com.thinkbiganalytics.spark.rest.model.TransformResponse) Nonnull(javax.annotation.Nonnull)

Aggregations

DataSet (com.thinkbiganalytics.spark.DataSet)1 QueryResultRowTransform (com.thinkbiganalytics.spark.metadata.QueryResultRowTransform)1 ShellTransformStage (com.thinkbiganalytics.spark.metadata.ShellTransformStage)1 TransformQueryResult (com.thinkbiganalytics.spark.rest.model.TransformQueryResult)1 TransformResponse (com.thinkbiganalytics.spark.rest.model.TransformResponse)1 Nonnull (javax.annotation.Nonnull)1 StructType (org.apache.spark.sql.types.StructType)1