Search in sources :

Example 91 with MaterializedRow

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);
    }
}
Also used : ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) MaterializedRow(com.facebook.presto.testing.MaterializedRow) OptionalDouble(java.util.OptionalDouble)

Aggregations

MaterializedRow (com.facebook.presto.testing.MaterializedRow)91 MaterializedResult (com.facebook.presto.testing.MaterializedResult)80 Test (org.testng.annotations.Test)67 AbstractTestIntegrationSmokeTest (com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)31 ImmutableList (com.google.common.collect.ImmutableList)16 Constraint (com.facebook.presto.spi.Constraint)15 ConnectorSession (com.facebook.presto.spi.ConnectorSession)14 Language (org.intellij.lang.annotations.Language)13 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)12 List (java.util.List)11 Session (com.facebook.presto.Session)10 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)10 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)10 ColumnHandle (com.facebook.presto.spi.ColumnHandle)9 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)9 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)9 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)9 UUID (java.util.UUID)9 Assert.assertEquals (org.testng.Assert.assertEquals)9 ImmutableMap (com.google.common.collect.ImmutableMap)8