Search in sources :

Example 1 with TestingPrestoClient

use of com.facebook.presto.tests.TestingPrestoClient in project presto by prestodb.

the class KafkaQueryRunner method createKafkaQueryRunner.

public static DistributedQueryRunner createKafkaQueryRunner(EmbeddedKafka embeddedKafka, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = new DistributedQueryRunner(createSession(), 2);
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        embeddedKafka.start();
        for (TpchTable<?> table : tables) {
            embeddedKafka.createTopics(kafkaTopicName(table));
        }
        Map<SchemaTableName, KafkaTopicDescription> topicDescriptions = createTpchTopicDescriptions(queryRunner.getCoordinator().getMetadata(), tables, embeddedKafka);
        installKafkaPlugin(embeddedKafka, queryRunner, topicDescriptions);
        TestingPrestoClient prestoClient = queryRunner.getRandomClient();
        log.info("Loading data...");
        long startTime = System.nanoTime();
        for (TpchTable<?> table : tables) {
            loadTpchTopic(embeddedKafka, prestoClient, table);
        }
        log.info("Loading complete in %s", nanosSince(startTime).toString(SECONDS));
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner, embeddedKafka);
        throw e;
    }
}
Also used : TestingPrestoClient(com.facebook.presto.tests.TestingPrestoClient) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Example 2 with TestingPrestoClient

use of com.facebook.presto.tests.TestingPrestoClient in project presto by prestodb.

the class AbstractTestHiveFunctions method setup.

@BeforeClass
public void setup() throws Exception {
    // TODO: Use DistributedQueryRunner to perform query
    server = createTestingPrestoServer();
    client = new TestingPrestoClient(server, testSessionBuilder().setTimeZoneKey(TimeZoneKey.getTimeZoneKey("America/Bahia_Banderas")).build());
    typeManager = server.getInstance(Key.get(TypeManager.class));
    if (getInitScript().isPresent()) {
        String sql = Files.asCharSource(getInitScript().get(), UTF_8).read();
        Iterable<String> initQueries = Splitter.on("----\n").omitEmptyStrings().trimResults().split(sql);
        for (@Language("SQL") String query : initQueries) {
            log.debug("Executing %s", query);
            client.execute(query);
        }
    }
}
Also used : TestingPrestoClient(com.facebook.presto.tests.TestingPrestoClient) Language(org.intellij.lang.annotations.Language) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with TestingPrestoClient

use of com.facebook.presto.tests.TestingPrestoClient in project presto by prestodb.

the class ElasticsearchQueryRunner method createElasticsearchQueryRunner.

public static DistributedQueryRunner createElasticsearchQueryRunner(EmbeddedElasticsearchNode embeddedElasticsearchNode, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = DistributedQueryRunner.builder(createSession()).setNodeCount(NODE_COUNT).build();
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        embeddedElasticsearchNode.start();
        TestingElasticsearchConnectorFactory testFactory = new TestingElasticsearchConnectorFactory();
        installElasticsearchPlugin(queryRunner, testFactory);
        TestingPrestoClient prestoClient = queryRunner.getRandomClient();
        LOG.info("Loading data...");
        long startTime = System.nanoTime();
        for (TpchTable<?> table : tables) {
            loadTpchTopic(embeddedElasticsearchNode, prestoClient, table);
        }
        LOG.info("Loading complete in %s", nanosSince(startTime).toString(SECONDS));
        return queryRunner;
    } catch (Exception e) {
        closeAllSuppress(e, queryRunner, embeddedElasticsearchNode);
        throw e;
    }
}
Also used : TestingPrestoClient(com.facebook.presto.tests.TestingPrestoClient) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin)

Example 4 with TestingPrestoClient

use of com.facebook.presto.tests.TestingPrestoClient in project presto by prestodb.

the class RedisQueryRunner method createRedisQueryRunner.

public static DistributedQueryRunner createRedisQueryRunner(EmbeddedRedis embeddedRedis, String dataFormat, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = new DistributedQueryRunner(createSession(), 2);
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        embeddedRedis.start();
        Map<SchemaTableName, RedisTableDescription> tableDescriptions = createTpchTableDescriptions(queryRunner.getCoordinator().getMetadata(), tables, dataFormat);
        installRedisPlugin(embeddedRedis, queryRunner, tableDescriptions);
        TestingPrestoClient prestoClient = queryRunner.getRandomClient();
        log.info("Loading data...");
        long startTime = System.nanoTime();
        for (TpchTable<?> table : tables) {
            loadTpchTable(embeddedRedis, prestoClient, table, dataFormat);
        }
        log.info("Loading complete in %s", nanosSince(startTime).toString(SECONDS));
        embeddedRedis.destroyJedisPool();
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner, embeddedRedis);
        throw e;
    }
}
Also used : TestingPrestoClient(com.facebook.presto.tests.TestingPrestoClient) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) SchemaTableName(com.facebook.presto.spi.SchemaTableName)

Aggregations

TestingPrestoClient (com.facebook.presto.tests.TestingPrestoClient)4 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)3 SchemaTableName (com.facebook.presto.spi.SchemaTableName)2 Language (org.intellij.lang.annotations.Language)1 BeforeClass (org.testng.annotations.BeforeClass)1