public DistributedQueryRunner build() throws Exception { return new DistributedQueryRunner(defaultSession, nodeCount, extraProperties, coordinatorProperties, parserOptions, environment); } }
private static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(testSessionBuilder().build(), DEFAULT_WORKER_COUNT, extraProperties); queryRunner.installPlugin(new GeoPlugin()); return queryRunner; }
private static QueryRunner createQueryRunner() throws Exception { Session session = testSessionBuilder() .setCatalog("test") .setSchema("default") .build(); return new DistributedQueryRunner(session, 1); }
public static DistributedQueryRunner createQueryRunner() throws Exception { Session defaultSession = testSessionBuilder() .setCatalog("tpch") .setSchema(TINY_SCHEMA_NAME) .setSystemProperty(SystemSessionProperties.TASK_CONCURRENCY, "2") .setSystemProperty(SystemSessionProperties.SPILL_ENABLED, "true") .setSystemProperty(SystemSessionProperties.AGGREGATION_OPERATOR_UNSPILL_MEMORY_LIMIT, "128kB") .build(); ImmutableMap<String, String> extraProperties = ImmutableMap.<String, String>builder() .put("experimental.spiller-spill-path", Paths.get(System.getProperty("java.io.tmpdir"), "presto", "spills").toString()) .put("experimental.spiller-max-used-space-threshold", "1.0") .put("experimental.memory-revoking-threshold", "0.0") // revoke always .put("experimental.memory-revoking-target", "0.0") .build(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(defaultSession, 2, extraProperties); try { queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); return queryRunner; } catch (Exception e) { queryRunner.close(); throw e; } }
public static DistributedQueryRunner createQueryRunner(Session session, Map<String, String> properties) throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 2, properties); try { queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); return queryRunner; } catch (Exception e) { queryRunner.close(); throw e; } } }
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public static DistributedQueryRunner createJmxQueryRunner() throws Exception { DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); queryRunner.installPlugin(new JmxPlugin()); queryRunner.createCatalog("jmx", "jmx"); return queryRunner; } catch (Throwable e) { closeAllSuppress(e, queryRunner); throw e; } }
public static QueryRunner createMySqlQueryRunner(TestingMySqlServer server, Iterable<TpchTable<?>> tables) throws Exception { DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); Map<String, String> properties = ImmutableMap.<String, String>builder() .put("connection-url", server.getJdbcUrl()) .put("allow-drop-table", "true") .build(); queryRunner.installPlugin(new MySqlPlugin()); queryRunner.createCatalog("mysql", "mysql", properties); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables); return queryRunner; } catch (Throwable e) { closeAllSuppress(e, queryRunner, server); throw e; } }
public static synchronized DistributedQueryRunner createAccumuloQueryRunner(Map<String, String> extraProperties) throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 4, extraProperties); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); queryRunner.installPlugin(new AccumuloPlugin()); Map<String, String> accumuloProperties = ImmutableMap.<String, String>builder() .put(AccumuloConfig.INSTANCE, connector.getInstance().getInstanceName()) .put(AccumuloConfig.ZOOKEEPERS, connector.getInstance().getZooKeepers()) .put(AccumuloConfig.USERNAME, MAC_USER) .put(AccumuloConfig.PASSWORD, MAC_PASSWORD) .put(AccumuloConfig.ZOOKEEPER_METADATA_ROOT, "/presto-accumulo-test") .build(); queryRunner.createCatalog("accumulo", "accumulo", accumuloProperties); if (!tpchLoaded) { copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), TpchTable.getTables()); connector.tableOperations().addSplits("tpch.orders", ImmutableSortedSet.of(new Text(new LexicoderRowSerializer().encode(BIGINT, 7500L)))); tpchLoaded = true; } return queryRunner; }
@BeforeClass private void setUp() throws Exception { session = testSessionBuilder() .setSystemProperty("task_concurrency", "1") .setCatalog("tpch") .setSchema("tiny") .setClientInfo("{\"clientVersion\":\"testVersion\"}") .build(); queryRunner = new DistributedQueryRunner(session, 1); queryRunner.installPlugin(new TpchPlugin()); queryRunner.installPlugin(new TestingEventListenerPlugin(generatedEvents)); queryRunner.installPlugin(new ResourceGroupManagerPlugin()); queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of("tpch.splits-per-node", Integer.toString(SPLITS_PER_NODE))); queryRunner.getCoordinator().getResourceGroupManager().get() .setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_simple.json"))); }
public static QueryRunner createPostgreSqlQueryRunner(TestingPostgreSqlServer server, Iterable<TpchTable<?>> tables) throws Exception { DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); Map<String, String> properties = ImmutableMap.<String, String>builder() .put("connection-url", server.getJdbcUrl()) .put("allow-drop-table", "true") .build(); createSchema(server.getJdbcUrl(), "tpch"); queryRunner.installPlugin(new PostgreSqlPlugin()); queryRunner.createCatalog("postgresql", "postgresql", properties); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables); return queryRunner; } catch (Throwable e) { closeAllSuppress(e, queryRunner, server); throw e; } }
@Test public void testCharTrailingSpace() throws Exception { execute("CREATE TABLE tpch.char_trailing_space (x char(10))"); assertUpdate("INSERT INTO char_trailing_space VALUES ('test')", 1); assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test'", "VALUES 'test'"); assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test '", "VALUES 'test'"); assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test '", "VALUES 'test'"); assertEquals(getQueryRunner().execute("SELECT * FROM char_trailing_space WHERE x = char ' test'").getRowCount(), 0); Map<String, String> properties = ImmutableMap.of("deprecated.legacy-char-to-varchar-coercion", "true"); Map<String, String> connectorProperties = ImmutableMap.of("connection-url", postgreSqlServer.getJdbcUrl()); try (QueryRunner queryRunner = new DistributedQueryRunner(getSession(), 3, properties);) { queryRunner.installPlugin(new PostgreSqlPlugin()); queryRunner.createCatalog("postgresql", "postgresql", connectorProperties); assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test'").getRowCount(), 0); assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test '").getRowCount(), 0); assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test '").getRowCount(), 0); MaterializedResult result = queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test '"); assertEquals(result.getRowCount(), 1); assertEquals(result.getMaterializedRows().get(0).getField(0), "test "); } assertUpdate("DROP TABLE char_trailing_space"); }
private static DistributedQueryRunner createQueryRunner() throws Exception { Session session = testSessionBuilder() .setCatalog("tpch_indexed") .setSchema(TINY_SCHEMA_NAME) .build(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 3); queryRunner.installPlugin(new IndexedTpchPlugin(INDEX_SPEC)); queryRunner.createCatalog("tpch_indexed", "tpch_indexed"); return queryRunner; } }
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception { Session session = testSessionBuilder() .setCatalog("blackhole") .setSchema("default") .build(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 4, extraProperties); try { queryRunner.installPlugin(new BlackHolePlugin()); queryRunner.createCatalog("blackhole", "blackhole", ImmutableMap.of()); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of()); return queryRunner; } catch (Exception e) { closeAllSuppress(e, queryRunner); throw e; } }
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception { Session session = testSessionBuilder() .setCatalog(CATALOG) .setSchema("default") .build(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 4, extraProperties); try { queryRunner.installPlugin(new MemoryPlugin()); queryRunner.createCatalog(CATALOG, "memory", ImmutableMap.of()); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of()); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, session, TpchTable.getTables()); return queryRunner; } catch (Exception e) { closeAllSuppress(e, queryRunner); throw e; } }
private static DistributedQueryRunner createQueryRunner() throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(testSessionBuilder() .setSource(TestSpatialJoins.class.getSimpleName()) .setCatalog("hive") .setSchema("default") .build(), 4); queryRunner.installPlugin(new GeoPlugin()); File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("hive_data").toFile(); HiveClientConfig hiveClientConfig = new HiveClientConfig(); HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationUpdater(hiveClientConfig)); HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hiveClientConfig, new NoHdfsAuthentication()); FileHiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test"); metastore.createDatabase(Database.builder() .setDatabaseName("default") .setOwnerName("public") .setOwnerType(PrincipalType.ROLE) .build()); queryRunner.installPlugin(new HivePlugin("hive", Optional.of(metastore))); queryRunner.createCatalog("hive", "hive"); return queryRunner; }
public static synchronized DistributedQueryRunner createCassandraQueryRunner() throws Exception { EmbeddedCassandra.start(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(createCassandraSession("tpch"), 4); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); queryRunner.installPlugin(new CassandraPlugin()); queryRunner.createCatalog("cassandra", "cassandra", ImmutableMap.of( "cassandra.contact-points", EmbeddedCassandra.getHost(), "cassandra.native-protocol-port", Integer.toString(EmbeddedCassandra.getPort()), "cassandra.allow-drop-table", "true")); if (!tpchLoaded) { createKeyspace(EmbeddedCassandra.getSession(), "tpch"); List<TpchTable<?>> tables = TpchTable.getTables(); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createCassandraSession("tpch"), tables); for (TpchTable table : tables) { EmbeddedCassandra.refreshSizeEstimates("tpch", table.getTableName()); } tpchLoaded = true; } return queryRunner; }
@Test public void testCharTrailingSpace() throws Exception { execute("CREATE TABLE tpch.char_trailing_space (x char(10))"); assertUpdate("INSERT INTO char_trailing_space VALUES ('test')", 1); assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test'", "VALUES 'test'"); assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test '", "VALUES 'test'"); assertQuery("SELECT * FROM char_trailing_space WHERE x = char 'test '", "VALUES 'test'"); assertEquals(getQueryRunner().execute("SELECT * FROM char_trailing_space WHERE x = char ' test'").getRowCount(), 0); Map<String, String> properties = ImmutableMap.of("deprecated.legacy-char-to-varchar-coercion", "true"); Map<String, String> connectorProperties = ImmutableMap.of("connection-url", mysqlServer.getJdbcUrl()); try (QueryRunner queryRunner = new DistributedQueryRunner(getSession(), 3, properties);) { queryRunner.installPlugin(new MySqlPlugin()); queryRunner.createCatalog("mysql", "mysql", connectorProperties); assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test'").getRowCount(), 0); assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test '").getRowCount(), 0); assertEquals(queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test '").getRowCount(), 0); MaterializedResult result = queryRunner.execute("SELECT * FROM char_trailing_space WHERE x = char 'test '"); assertEquals(result.getRowCount(), 1); assertEquals(result.getMaterializedRows().get(0).getField(0), "test "); } assertUpdate("DROP TABLE char_trailing_space"); }
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.getClient(); 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; } }
public static DistributedQueryRunner createJdbcQueryRunner(Iterable<TpchTable<?>> tables) throws Exception { DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); Map<String, String> properties = TestingH2JdbcModule.createProperties(); createSchema(properties, "tpch"); queryRunner.installPlugin(new JdbcPlugin("base-jdbc", new TestingH2JdbcModule())); queryRunner.createCatalog("jdbc", "base-jdbc", properties); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables); return queryRunner; } catch (Throwable e) { closeAllSuppress(e, queryRunner); throw e; } }
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); installKafkaPlugin(embeddedKafka, queryRunner, topicDescriptions); TestingPrestoClient prestoClient = queryRunner.getClient(); 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; } }