Search in sources :

Example 1 with SaveSqlStage

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

the class TransformService method saveSql.

/**
 * Executes and saves a Spark SQL request.
 */
@Nonnull
public SaveResponse saveSql(@Nonnull final String id, @Nonnull final SaveRequest save) {
    log.entry(id, save);
    // Create task
    final Supplier<SaveResult> task;
    final TransformRequest transform = getTransformRequest(id);
    final JdbcDatasource transformDatasource = (transform.getDatasources() != null && transform.getDatasources().size() == 1 && transform.getDatasources().get(0) instanceof JdbcDatasource) ? (JdbcDatasource) transform.getDatasources().get(0) : null;
    if (transformDatasource != null && save.getJdbc() != null && Objects.equal(transformDatasource.getId(), save.getJdbc().getId())) {
        Preconditions.checkArgument(save.getTableName() != null, "Missing target table name.");
        task = new SaveSqlStage(save.getTableName(), transform.getScript(), save.getJdbc());
    } else {
        task = createSaveTask(save, createSqlTask(transform));
    }
    // Submit job
    final SaveResponse response = submitSaveJob(task);
    return log.exit(response);
}
Also used : JdbcDatasource(com.thinkbiganalytics.spark.rest.model.JdbcDatasource) SaveSqlStage(com.thinkbiganalytics.spark.metadata.SaveSqlStage) SaveResponse(com.thinkbiganalytics.spark.rest.model.SaveResponse) SaveResult(com.thinkbiganalytics.spark.model.SaveResult) TransformRequest(com.thinkbiganalytics.spark.rest.model.TransformRequest) Nonnull(javax.annotation.Nonnull)

Aggregations

SaveSqlStage (com.thinkbiganalytics.spark.metadata.SaveSqlStage)1 SaveResult (com.thinkbiganalytics.spark.model.SaveResult)1 JdbcDatasource (com.thinkbiganalytics.spark.rest.model.JdbcDatasource)1 SaveResponse (com.thinkbiganalytics.spark.rest.model.SaveResponse)1 TransformRequest (com.thinkbiganalytics.spark.rest.model.TransformRequest)1 Nonnull (javax.annotation.Nonnull)1