use of com.facebook.presto.testing.MaterializedRow in project presto by prestodb.
the class MetricComparator method getActualValues.
private static List<OptionalDouble> getActualValues(List<Metric> metrics, String query, QueryRunner runner) {
String statsQuery = "SELECT " + metrics.stream().map(Metric::getComputingAggregationSql).collect(joining(",")) + " FROM (" + query + ")";
try {
MaterializedRow actualValuesRow = getOnlyElement(runner.execute(statsQuery).getMaterializedRows());
ImmutableList.Builder<OptionalDouble> actualValues = ImmutableList.builder();
for (int i = 0; i < metrics.size(); ++i) {
actualValues.add(metrics.get(i).getValueFromAggregationQueryResult(actualValuesRow.getField(i)));
}
return actualValues.build();
} catch (Exception e) {
throw new RuntimeException(format("Failed to execute query to compute actual values: %s", statsQuery), e);
}
}
Aggregations