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