use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestDistributedQueries method testRenameTable.
@Test
public void testRenameTable() {
assertUpdate("CREATE TABLE test_rename AS SELECT 123 x", 1);
assertUpdate("ALTER TABLE test_rename RENAME TO test_rename_new");
MaterializedResult materializedRows = computeActual("SELECT x FROM test_rename_new");
assertEquals(getOnlyElement(materializedRows.getMaterializedRows()).getField(0), 123);
// provide new table name in uppercase
assertUpdate("ALTER TABLE test_rename_new RENAME TO TEST_RENAME");
materializedRows = computeActual("SELECT x FROM test_rename");
assertEquals(getOnlyElement(materializedRows.getMaterializedRows()).getField(0), 123);
assertUpdate("DROP TABLE test_rename");
assertFalse(getQueryRunner().tableExists(getSession(), "test_rename"));
assertFalse(getQueryRunner().tableExists(getSession(), "test_rename_new"));
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestDistributedQueries method testTableSampleSystemBoundaryValues.
@Test
public void testTableSampleSystemBoundaryValues() {
MaterializedResult fullSample = computeActual("SELECT orderkey FROM orders TABLESAMPLE SYSTEM (100)");
MaterializedResult emptySample = computeActual("SELECT orderkey FROM orders TABLESAMPLE SYSTEM (0)");
MaterializedResult all = computeActual("SELECT orderkey FROM orders");
assertContains(all, fullSample);
assertEquals(emptySample.getMaterializedRows().size(), 0);
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestIndexedQueries method testExampleSystemTable.
@Test
public void testExampleSystemTable() throws Exception {
assertQuery("SELECT name FROM sys.example", "SELECT 'test' AS name");
MaterializedResult result = computeActual("SHOW SCHEMAS");
assertTrue(result.getOnlyColumnAsSet().containsAll(ImmutableSet.of("sf100", "tiny", "sys")));
result = computeActual("SHOW TABLES FROM sys");
assertEquals(result.getOnlyColumnAsSet(), ImmutableSet.of("example"));
}
use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.
the class AbstractTestIntegrationSmokeTest method testShowTables.
@Test
public void testShowTables() throws Exception {
MaterializedResult actualTables = computeActual("SHOW TABLES").toJdbcTypes();
MaterializedResult expectedTables = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR).row("orders").build();
assertContains(actualTables, expectedTables);
}
use of com.facebook.presto.testing.MaterializedResult 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());
}
}
Aggregations