use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.
the class TestQueryStateInfoResource method setUp.
@BeforeClass
public void setUp() {
server = TestingTrinoServer.create();
server.installPlugin(new TpchPlugin());
server.createCatalog("tpch", "tpch");
client = new JettyHttpClient();
Request request1 = preparePost().setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build()).setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8)).setHeader(TRINO_HEADERS.requestUser(), "user1").build();
queryResults = client.execute(request1, createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC));
client.execute(prepareGet().setUri(queryResults.getNextUri()).build(), createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC));
Request request2 = preparePost().setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build()).setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8)).setHeader(TRINO_HEADERS.requestUser(), "user2").build();
QueryResults queryResults2 = client.execute(request2, createJsonResponseHandler(jsonCodec(QueryResults.class)));
client.execute(prepareGet().setUri(queryResults2.getNextUri()).build(), createJsonResponseHandler(QUERY_RESULTS_JSON_CODEC));
// queries are started in the background, so they may not all be immediately visible
long start = System.nanoTime();
while (Duration.nanosSince(start).compareTo(new Duration(5, MINUTES)) < 0) {
List<BasicQueryInfo> queryInfos = client.execute(prepareGet().setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/query").build()).setHeader(TRINO_HEADERS.requestUser(), "unknown").build(), createJsonResponseHandler(listJsonCodec(BasicQueryInfo.class)));
if (queryInfos.size() == 2) {
if (queryInfos.stream().allMatch(info -> info.getState() == RUNNING)) {
break;
}
List<ErrorCode> errorCodes = queryInfos.stream().filter(info -> info.getState() == FAILED).map(BasicQueryInfo::getErrorCode).collect(toImmutableList());
if (!errorCodes.isEmpty()) {
fail("setup queries failed with: " + errorCodes);
}
}
}
}
use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.
the class TestQueryResource method setup.
@BeforeMethod
public void setup() {
client = new JettyHttpClient();
server = TestingTrinoServer.create();
server.installPlugin(new TpchPlugin());
server.createCatalog("tpch", "tpch");
}
use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.
the class H2QueryRunner method createH2QueryRunner.
public static DistributedQueryRunner createH2QueryRunner(Iterable<TpchTable<?>> tables, Map<String, String> properties, Module module) throws Exception {
DistributedQueryRunner queryRunner = null;
try {
queryRunner = DistributedQueryRunner.builder(createSession()).build();
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
createSchema(properties, "tpch");
queryRunner.installPlugin(new JdbcPlugin("base-jdbc", module));
queryRunner.createCatalog("jdbc", "base-jdbc", properties);
copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
return queryRunner;
} catch (Throwable e) {
closeAllSuppress(e, queryRunner);
throw e;
}
}
use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.
the class DeltaLakeQueryRunner method createDeltaLakeQueryRunner.
public static DistributedQueryRunner createDeltaLakeQueryRunner(Map<String, String> extraProperties, Map<String, String> connectorProperties) throws Exception {
Session session = testSessionBuilder().setCatalog(DELTA_CATALOG).setSchema("tpch").build();
DistributedQueryRunner.Builder<?> builder = DistributedQueryRunner.builder(session);
extraProperties.forEach(builder::addExtraProperty);
DistributedQueryRunner queryRunner = builder.build();
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
Path dataDir = queryRunner.getCoordinator().getBaseDataDir().resolve(DELTA_CATALOG);
connectorProperties = new HashMap<>(ImmutableMap.copyOf(connectorProperties));
connectorProperties.putIfAbsent("hive.metastore", "file");
connectorProperties.putIfAbsent("hive.metastore.catalog.dir", dataDir.toString());
queryRunner.installPlugin(new TestingDeltaLakePlugin());
queryRunner.createCatalog(DELTA_CATALOG, CONNECTOR_NAME, connectorProperties);
queryRunner.execute("CREATE SCHEMA tpch");
return queryRunner;
}
use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.
the class BigQueryQueryRunner method createQueryRunner.
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties, Map<String, String> connectorProperties) throws Exception {
DistributedQueryRunner queryRunner = null;
try {
queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).build();
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
connectorProperties = new HashMap<>(ImmutableMap.copyOf(connectorProperties));
connectorProperties.putIfAbsent("bigquery.views-enabled", "true");
connectorProperties.putIfAbsent("bigquery.view-expire-duration", "30m");
queryRunner.installPlugin(new BigQueryPlugin());
queryRunner.createCatalog("bigquery", "bigquery", connectorProperties);
return queryRunner;
} catch (Throwable e) {
closeAllSuppress(e, queryRunner);
throw e;
}
}
Aggregations