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