Search in sources :

Example 1 with ShellTransformStage

use of com.thinkbiganalytics.spark.metadata.ShellTransformStage 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)

Example 2 with ShellTransformStage

use of com.thinkbiganalytics.spark.metadata.ShellTransformStage in project kylo by Teradata.

the class TransformService method saveShell.

/**
 * Executes and saves a Spark shell request.
 */
@Nonnull
public SaveResponse saveShell(@Nonnull final String id, @Nonnull final SaveRequest save) throws ScriptException {
    log.entry(id, save);
    final DataSet dataSet = createShellTask(getTransformRequest(id));
    final SaveResponse response = submitSaveJob(createSaveTask(save, new ShellTransformStage(dataSet)));
    return log.exit(response);
}
Also used : DataSet(com.thinkbiganalytics.spark.DataSet) SaveResponse(com.thinkbiganalytics.spark.rest.model.SaveResponse) ShellTransformStage(com.thinkbiganalytics.spark.metadata.ShellTransformStage) Nonnull(javax.annotation.Nonnull)

Aggregations

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