Search in sources :

Example 26 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class TestHiveDistributedJoinQueriesWithDynamicFiltering method testJoinWithSelectiveBuildSide.

@Test
public void testJoinWithSelectiveBuildSide() {
    Session session = Session.builder(getSession()).setSystemProperty(JOIN_DISTRIBUTION_TYPE, FeaturesConfig.JoinDistributionType.BROADCAST.name()).build();
    DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
    ResultWithQueryId<MaterializedResult> result = runner.executeWithQueryId(session, "SELECT * FROM lineitem JOIN orders ON lineitem.orderkey = orders.orderkey AND orders.custkey = 1");
    assertGreaterThan(result.getResult().getRowCount(), 0);
    OperatorStats probeStats = searchScanFilterAndProjectOperatorStats(result.getQueryId(), "tpch:lineitem");
    // Probe side may be partially scanned, depending on the drivers' scheduling:
    assertLessThanOrEqual(probeStats.getInputPositions(), countRows("lineitem"));
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) OperatorStats(io.prestosql.operator.OperatorStats) MaterializedResult(io.prestosql.testing.MaterializedResult) Session(io.prestosql.Session) TestingConnectorSession(io.prestosql.testing.TestingConnectorSession) Test(org.testng.annotations.Test)

Example 27 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class TestHiveDistributedJoinQueriesWithDynamicFiltering method searchScanFilterAndProjectOperatorStats.

private OperatorStats searchScanFilterAndProjectOperatorStats(QueryId queryId, String tableName) {
    DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
    Plan plan = runner.getQueryPlan(queryId);
    PlanNodeId nodeId = PlanNodeSearcher.searchFrom(plan.getRoot()).where(node -> {
        if (!(node instanceof ProjectNode)) {
            return false;
        }
        ProjectNode projectNode = (ProjectNode) node;
        FilterNode filterNode = (FilterNode) projectNode.getSource();
        TableScanNode tableScanNode = (TableScanNode) filterNode.getSource();
        return tableName.equals(tableScanNode.getTable().getConnectorHandle().toString());
    }).findOnlyElement().getId();
    return runner.getCoordinator().getQueryManager().getFullQueryInfo(queryId).getQueryStats().getOperatorSummaries().stream().filter(summary -> nodeId.equals(summary.getPlanNodeId())).collect(MoreCollectors.onlyElement());
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) DynamicFilter(io.prestosql.spi.dynamicfilter.DynamicFilter) HiveTestUtils.getDefaultHiveSelectiveFactories(io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveSelectiveFactories) Assertions.assertGreaterThan(io.airlift.testing.Assertions.assertGreaterThan) Plan(io.prestosql.sql.planner.Plan) Test(org.testng.annotations.Test) MaterializedResult(io.prestosql.testing.MaterializedResult) TypeSignature.parseTypeSignature(io.prestosql.spi.type.TypeSignature.parseTypeSignature) FilterNode(io.prestosql.spi.plan.FilterNode) ENABLE_DYNAMIC_FILTERING(io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Map(java.util.Map) Assert.assertFalse(org.testng.Assert.assertFalse) HIVE_INT(io.prestosql.plugin.hive.HiveType.HIVE_INT) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PrestoException(io.prestosql.spi.PrestoException) ImmutableMap(com.google.common.collect.ImmutableMap) HiveTestUtils.createTestHdfsEnvironment(io.prestosql.plugin.hive.HiveTestUtils.createTestHdfsEnvironment) MoreCollectors(com.google.common.collect.MoreCollectors) TableScanNode(io.prestosql.spi.plan.TableScanNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) HiveQueryRunner.createQueryRunnerWithStateStore(io.prestosql.plugin.hive.HiveQueryRunner.createQueryRunnerWithStateStore) TpchTable.getTables(io.airlift.tpch.TpchTable.getTables) AbstractTestQueryFramework(io.prestosql.tests.AbstractTestQueryFramework) List(java.util.List) ConnectorPageSource(io.prestosql.spi.connector.ConnectorPageSource) Optional(java.util.Optional) OperatorStats(io.prestosql.operator.OperatorStats) JOIN_DISTRIBUTION_TYPE(io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) StandardTypes(io.prestosql.spi.type.StandardTypes) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FixedPageSource(io.prestosql.spi.connector.FixedPageSource) TYPE_MANAGER(io.prestosql.plugin.hive.HiveTestUtils.TYPE_MANAGER) Assert.assertEquals(org.testng.Assert.assertEquals) OptionalInt(java.util.OptionalInt) Supplier(java.util.function.Supplier) BloomFilter(io.prestosql.spi.util.BloomFilter) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertLessThanOrEqual(io.airlift.testing.Assertions.assertLessThanOrEqual) PARTITION_KEY(io.prestosql.plugin.hive.HiveColumnHandle.ColumnType.PARTITION_KEY) Session(io.prestosql.Session) DynamicFilterSupplier(io.prestosql.spi.dynamicfilter.DynamicFilterSupplier) QueryId(io.prestosql.spi.QueryId) HiveTestUtils.getNoOpIndexCache(io.prestosql.plugin.hive.HiveTestUtils.getNoOpIndexCache) Properties(java.util.Properties) DYNAMIC_FILTERING_WAIT_TIME(io.prestosql.SystemSessionProperties.DYNAMIC_FILTERING_WAIT_TIME) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle) HiveTestUtils.getDefaultHiveRecordCursorProvider(io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveRecordCursorProvider) Assert.fail(org.testng.Assert.fail) IOException(java.io.IOException) HiveTestUtils.getDefaultHiveDataStreamFactories(io.prestosql.plugin.hive.HiveTestUtils.getDefaultHiveDataStreamFactories) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) PlanNodeSearcher(io.prestosql.sql.planner.optimizations.PlanNodeSearcher) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) Assert.assertTrue(org.testng.Assert.assertTrue) TestingConnectorSession(io.prestosql.testing.TestingConnectorSession) DynamicFilterFactory(io.prestosql.spi.dynamicfilter.DynamicFilterFactory) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) TableScanNode(io.prestosql.spi.plan.TableScanNode) FilterNode(io.prestosql.spi.plan.FilterNode) ProjectNode(io.prestosql.spi.plan.ProjectNode) Plan(io.prestosql.sql.planner.Plan)

Example 28 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class HetuTestServer method startServer.

public void startServer(String dbName, Map<String, String> properties) throws Exception {
    queryRunner = new DistributedQueryRunner(createSession(), 4, hetuProperties);
    this.dbName = dbName;
    startServer(properties);
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner)

Example 29 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class HetuTestServer method startServer.

public void startServer(Map<String, String> properties) throws Exception {
    carbonProperties.putAll(properties);
    logger.info("------------ Starting Presto Server -------------");
    DistributedQueryRunner distributedQueryRunner = createQueryRunner(hetuProperties);
    Connection connection = createJdbcConnection(dbName);
    statement = (PrestoStatement) connection.createStatement();
    logger.info("STARTED SERVER AT :" + distributedQueryRunner.getCoordinator().getBaseUrl());
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Connection(java.sql.Connection)

Example 30 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class HindexQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties, Map<String, String> metastoreProperties, Map<String, String> coordinatorProperties) throws Exception {
    Session session = testSessionBuilder().setSource("test").setCatalog("hive").setSchema("test").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(1).setExtraProperties(extraProperties).setCoordinatorProperties(coordinatorProperties).build();
    try {
        File tempDir = Files.createTempDirectory("test-hive").toFile();
        File hiveDir = new File(tempDir, "hive_data");
        HiveMetastore metastore = createTestingFileHiveMetastore(hiveDir);
        HiveIdentity identity = new HiveIdentity(SESSION);
        metastore.createDatabase(identity, Database.builder().setDatabaseName("test").setOwnerName("public").setOwnerType(PrincipalType.ROLE).build());
        queryRunner.installPlugin(new HetuFileSystemClientPlugin());
        queryRunner.installPlugin(new HetuMetastorePlugin());
        queryRunner.installPlugin(new HiveHadoop2Plugin());
        queryRunner.installPlugin(new HeuristicIndexPlugin());
        queryRunner.installPlugin(new HivePlugin("Hive", Optional.of(metastore)));
        queryRunner.getServers().forEach(server -> {
            try {
                server.loadMetastore(metastoreProperties);
                server.getHeuristicIndexerManager().buildIndexClient();
                server.getHeuristicIndexerManager().initCache();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        Map<String, String> hiveProperties = ImmutableMap.<String, String>builder().put("hive.allow-drop-table", "true").build();
        queryRunner.createCatalog("hive", "Hive", hiveProperties);
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : HetuFileSystemClientPlugin(io.hetu.core.filesystem.HetuFileSystemClientPlugin) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) FileHiveMetastore.createTestingFileHiveMetastore(io.prestosql.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore) HiveMetastore(io.prestosql.plugin.hive.metastore.HiveMetastore) HivePlugin(io.prestosql.plugin.hive.HivePlugin) HiveIdentity(io.prestosql.plugin.hive.authentication.HiveIdentity) HetuMetastorePlugin(io.hetu.core.metastore.HetuMetastorePlugin) HiveHadoop2Plugin(io.prestosql.plugin.hive.HiveHadoop2Plugin) File(java.io.File) Session(io.prestosql.Session)

Aggregations

DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)75 Test (org.testng.annotations.Test)28 TpchPlugin (io.prestosql.plugin.tpch.TpchPlugin)22 Session (io.prestosql.Session)16 QueryId (io.prestosql.spi.QueryId)13 MaterializedResult (io.prestosql.testing.MaterializedResult)13 ResourceGroupManagerPlugin (io.prestosql.plugin.resourcegroups.ResourceGroupManagerPlugin)11 Logger (io.airlift.log.Logger)10 HashMap (java.util.HashMap)8 ResultWithQueryId (io.prestosql.tests.ResultWithQueryId)7 List (java.util.List)7 Assert.assertTrue (org.testng.Assert.assertTrue)7 ImmutableSet (com.google.common.collect.ImmutableSet)6 ENABLE_DYNAMIC_FILTERING (io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING)6 JOIN_DISTRIBUTION_TYPE (io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)6 OperatorStats (io.prestosql.operator.OperatorStats)6 TestingPrestoServer (io.prestosql.server.testing.TestingPrestoServer)6 FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)6 TestingConnectorSession (io.prestosql.testing.TestingConnectorSession)6 AbstractTestQueryFramework (io.prestosql.tests.AbstractTestQueryFramework)6