Search in sources :

Example 71 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestJmxQueries method testShowSchemas.

@Test
public void testShowSchemas() throws Exception {
    MaterializedResult result = computeActual("SHOW SCHEMAS");
    assertEquals(result.getOnlyColumnAsSet(), ImmutableSet.of(INFORMATION_SCHEMA, JMX_SCHEMA_NAME, HISTORY_SCHEMA_NAME));
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 72 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestJmxQueries method testShowTables.

@Test
public void testShowTables() throws Exception {
    Set<String> standardNamesLower = STANDARD_NAMES.stream().map(String::toLowerCase).collect(toImmutableSet());
    MaterializedResult result = computeActual("SHOW TABLES");
    assertTrue(result.getOnlyColumnAsSet().containsAll(standardNamesLower));
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 73 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestManySegments method testManySegments.

@Test
public void testManySegments() throws Exception {
    MaterializedResult result = queryRunner.execute("SELECT count(_message) from " + topicName);
    MaterializedResult expected = MaterializedResult.resultBuilder(SESSION, BigintType.BIGINT).row(100000L).build();
    assertEquals(result, expected);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 74 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestRaptorIntegrationSmokeTest method testShardingByTemporalTimestampColumn.

@Test
public void testShardingByTemporalTimestampColumn() throws Exception {
    // Make sure we have at least 2 different orderdate.
    assertEquals(computeActual("SELECT count(DISTINCT orderdate) >= 2 FROM orders WHERE orderdate < date '1992-02-08'").getOnlyValue(), true);
    assertUpdate("CREATE TABLE test_shard_temporal_timestamp(col1 BIGINT, col2 TIMESTAMP) WITH (temporal_column = 'col2')");
    int rows = 20;
    StringJoiner joiner = new StringJoiner(", ", "INSERT INTO test_shard_temporal_timestamp VALUES ", "");
    for (int i = 0; i < rows; i++) {
        joiner.add(format("(%s, TIMESTAMP '2016-08-08 01:00' + interval '%s' hour)", i, i * 4));
    }
    assertUpdate(joiner.toString(), format("VALUES(%s)", rows));
    MaterializedResult results = computeActual("SELECT format_datetime(col2, 'yyyyMMdd'), \"$shard_uuid\" FROM test_shard_temporal_timestamp");
    assertEquals(results.getRowCount(), rows);
    // Each shard will only contain data of one date.
    SetMultimap<String, String> shardDateMap = HashMultimap.create();
    for (MaterializedRow row : results.getMaterializedRows()) {
        shardDateMap.put((String) row.getField(1), (String) row.getField(0));
    }
    for (Collection<String> dates : shardDateMap.asMap().values()) {
        assertEquals(dates.size(), 1);
    }
    // Ensure one shard can contain different timestamps from the same day
    assertLessThan(shardDateMap.size(), rows);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) StringJoiner(java.util.StringJoiner) MaterializedRow(com.facebook.presto.testing.MaterializedRow) Test(org.testng.annotations.Test) AbstractTestIntegrationSmokeTest(com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)

Example 75 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestShardCompactor method assertShardEqualsSorted.

private void assertShardEqualsSorted(Set<UUID> inputUuids, List<UUID> outputUuids, List<Long> columnIds, List<Type> columnTypes, List<Integer> sortIndexes, List<SortOrder> sortOrders) throws IOException {
    List<Page> inputPages = getPages(inputUuids, columnIds, columnTypes);
    List<Type> sortTypes = sortIndexes.stream().map(columnTypes::get).collect(toList());
    MaterializedResult inputRowsSorted = sortAndMaterialize(inputPages, columnTypes, sortIndexes, sortOrders, sortTypes);
    MaterializedResult outputRows = extractColumns(getMaterializedRows(outputUuids, columnIds, columnTypes), sortIndexes, sortTypes);
    assertEquals(outputRows, inputRowsSorted);
}
Also used : VarcharType.createVarcharType(com.facebook.presto.spi.type.VarcharType.createVarcharType) Type(com.facebook.presto.spi.type.Type) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult)

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