use of com.facebook.presto.spark.PrestoSparkQueryExecutionFactory.PrestoSparkQueryExecution in project presto by prestodb.
the class PrestoSparkQueryRunner method execute.
@Override
public MaterializedResult execute(Session session, String sql) {
IPrestoSparkQueryExecutionFactory executionFactory = prestoSparkService.getQueryExecutionFactory();
IPrestoSparkQueryExecution execution = executionFactory.create(sparkContext, createSessionInfo(session), Optional.of(sql), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), new TestingPrestoSparkTaskExecutorFactoryProvider(instanceId), Optional.empty(), Optional.empty());
List<List<Object>> results = execution.execute();
List<MaterializedRow> rows = results.stream().map(result -> new MaterializedRow(DEFAULT_PRECISION, result)).collect(toImmutableList());
if (execution instanceof PrestoSparkQueryExecution) {
PrestoSparkQueryExecution p = (PrestoSparkQueryExecution) execution;
if (!p.getUpdateType().isPresent()) {
return new MaterializedResult(rows, p.getOutputTypes());
} else {
return new MaterializedResult(rows, p.getOutputTypes(), ImmutableMap.of(), ImmutableSet.of(), p.getUpdateType(), OptionalLong.of((Long) getOnlyElement(getOnlyElement(rows).getFields())), ImmutableList.of());
}
} else {
return new MaterializedResult(rows, ImmutableList.of(), ImmutableMap.of(), ImmutableSet.of(), Optional.empty(), OptionalLong.empty(), ImmutableList.of());
}
}
Aggregations