Search in sources :

Example 96 with MaterializedResult

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"));
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 97 with MaterializedResult

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);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 98 with MaterializedResult

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"));
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 99 with MaterializedResult

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);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 100 with MaterializedResult

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

Aggregations

MaterializedResult (com.facebook.presto.testing.MaterializedResult)298 Test (org.testng.annotations.Test)255 Page (com.facebook.presto.spi.Page)75 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)54 MaterializedRow (com.facebook.presto.testing.MaterializedRow)52 Type (com.facebook.presto.spi.type.Type)43 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)35 Session (com.facebook.presto.Session)23 TestingTaskContext (com.facebook.presto.testing.TestingTaskContext)21 AbstractTestIntegrationSmokeTest (com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)20 ImmutableList (com.google.common.collect.ImmutableList)20 ColumnHandle (com.facebook.presto.spi.ColumnHandle)19 ConnectorSession (com.facebook.presto.spi.ConnectorSession)18 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)18 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)17 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)17 ImmutableMap (com.google.common.collect.ImmutableMap)17 List (java.util.List)17 BIGINT (com.facebook.presto.spi.type.BigintType.BIGINT)16 Path (org.apache.hadoop.fs.Path)14