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);
}
Aggregations