use of io.trino.testing.TestingTrinoClient in project trino by trinodb.
the class RedisQueryRunner method createRedisQueryRunner.
public static DistributedQueryRunner createRedisQueryRunner(RedisServer redisServer, Map<String, String> extraProperties, String dataFormat, Iterable<TpchTable<?>> tables) throws Exception {
DistributedQueryRunner queryRunner = null;
try {
queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).build();
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
Map<SchemaTableName, RedisTableDescription> tableDescriptions = createTpchTableDescriptions(queryRunner.getCoordinator().getTypeManager(), tables, dataFormat);
installRedisPlugin(redisServer, queryRunner, tableDescriptions);
TestingTrinoClient trinoClient = queryRunner.getClient();
log.info("Loading data...");
long startTime = System.nanoTime();
for (TpchTable<?> table : tables) {
loadTpchTable(redisServer, trinoClient, table, dataFormat);
}
log.info("Loading complete in %s", nanosSince(startTime).toString(SECONDS));
redisServer.destroyJedisPool();
return queryRunner;
} catch (Throwable e) {
closeAllSuppress(e, queryRunner, redisServer);
throw e;
}
}
use of io.trino.testing.TestingTrinoClient in project trino by trinodb.
the class ElasticsearchQueryRunner method createElasticsearchQueryRunner.
public static DistributedQueryRunner createElasticsearchQueryRunner(HostAndPort address, Iterable<TpchTable<?>> tables, Map<String, String> extraProperties, Map<String, String> extraConnectorProperties, int nodeCount) throws Exception {
RestHighLevelClient client = null;
DistributedQueryRunner queryRunner = null;
try {
queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).setNodeCount(nodeCount).build();
queryRunner.installPlugin(new JmxPlugin());
queryRunner.createCatalog("jmx", "jmx");
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
ElasticsearchConnectorFactory testFactory = new ElasticsearchConnectorFactory();
installElasticsearchPlugin(address, queryRunner, testFactory, extraConnectorProperties);
TestingTrinoClient trinoClient = queryRunner.getClient();
LOG.info("Loading data...");
client = new RestHighLevelClient(RestClient.builder(HttpHost.create(address.toString())));
long startTime = System.nanoTime();
for (TpchTable<?> table : tables) {
loadTpchTopic(client, trinoClient, table);
}
LOG.info("Loading complete in %s", nanosSince(startTime).toString(SECONDS));
return queryRunner;
} catch (Exception e) {
closeAllSuppress(e, queryRunner, client);
throw e;
}
}
use of io.trino.testing.TestingTrinoClient in project trino by trinodb.
the class TestServer method testVersionOnCompilerFailedError.
@Test
public void testVersionOnCompilerFailedError() {
String tableName = "memory.default.test_version_on_compiler_failed";
try (TestingTrinoClient testingClient = new TestingTrinoClient(server, testSessionBuilder().build())) {
testingClient.execute("DROP TABLE IF EXISTS " + tableName);
testingClient.execute("CREATE TABLE " + tableName + " AS SELECT '' as foo");
// This query is designed to cause a compile failure, and hopefully not run too long.
// The exact query is not important, just that it causes a failure.
String array = IntStream.range(0, 254).mapToObj(columnNumber -> "foo").collect(joining(", ", "ARRAY[", "]"));
String query = "SELECT " + String.join(" || ", Collections.nCopies(10, array)) + "FROM " + tableName;
checkVersionOnError(query, "TrinoException: Compiler failed(?s:.*)at io.trino.sql.gen.ExpressionCompiler.compile");
}
}
Aggregations