Search in sources :

Example 1 with TestTable

use of com.facebook.presto.tests.sql.TestTable in project presto by prestodb.

the class DataTypeTest method execute.

public void execute(QueryRunner prestoExecutor, DataSetup dataSetup) {
    List<Type> expectedTypes = inputs.stream().map(Input::getPrestoResultType).collect(toList());
    List<Object> expectedResults = inputs.stream().map(Input::toPrestoQueryResult).collect(toList());
    try (TestTable testTable = dataSetup.setupTestTable(unmodifiableList(inputs))) {
        MaterializedResult materializedRows = prestoExecutor.execute("SELECT * from " + testTable.getName());
        assertEquals(expectedTypes, materializedRows.getTypes());
        MaterializedRow row = getOnlyElement(materializedRows);
        assertEquals(expectedResults, row.getFields());
    }
}
Also used : Type(com.facebook.presto.spi.type.Type) TestTable(com.facebook.presto.tests.sql.TestTable) MaterializedResult(com.facebook.presto.testing.MaterializedResult) MaterializedRow(com.facebook.presto.testing.MaterializedRow)

Example 2 with TestTable

use of com.facebook.presto.tests.sql.TestTable in project presto by prestodb.

the class CreateAndInsertDataSetup method setupTestTable.

@Override
public TestTable setupTestTable(List<DataTypeTest.Input<?>> inputs) {
    TestTable testTable = createTestTable(inputs);
    insertRows(testTable, inputs);
    return testTable;
}
Also used : TestTable(com.facebook.presto.tests.sql.TestTable)

Example 3 with TestTable

use of com.facebook.presto.tests.sql.TestTable in project presto by prestodb.

the class DataTypeTest method execute.

public void execute(QueryRunner prestoExecutor, Session session, DataSetup dataSetup) {
    List<Type> expectedTypes = inputs.stream().map(Input::getPrestoResultType).collect(toList());
    List<Object> expectedResults = inputs.stream().map(Input::toPrestoQueryResult).collect(toList());
    try (TestTable testTable = dataSetup.setupTestTable(unmodifiableList(inputs))) {
        MaterializedResult materializedRows = prestoExecutor.execute(session, "SELECT * from " + testTable.getName());
        assertEquals(materializedRows.getTypes(), expectedTypes);
        List<Object> actualResults = getOnlyElement(materializedRows).getFields();
        assertEquals(actualResults.size(), expectedResults.size(), "lists don't have the same size");
        for (int i = 0; i < expectedResults.size(); i++) {
            assertEquals(actualResults.get(i), expectedResults.get(i), "Element " + i);
        }
    }
}
Also used : Type(com.facebook.presto.common.type.Type) TestTable(com.facebook.presto.tests.sql.TestTable) MaterializedResult(com.facebook.presto.testing.MaterializedResult)

Aggregations

TestTable (com.facebook.presto.tests.sql.TestTable)3 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2 Type (com.facebook.presto.common.type.Type)1 Type (com.facebook.presto.spi.type.Type)1 MaterializedRow (com.facebook.presto.testing.MaterializedRow)1