Search in sources :

Example 16 with LocalQueryRunner

use of io.prestosql.testing.LocalQueryRunner in project boostkit-bigdata by kunpengcompute.

the class HiveBenchmarkQueryRunner method createLocalQueryRunner.

public static LocalQueryRunner createLocalQueryRunner(File tempDir) {
    Session session = testSessionBuilder().setCatalog("hive").setSchema("tpch").build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);
    // add tpch
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    // add hive
    File hiveDir = new File(tempDir, "hive_data");
    HiveMetastore metastore = createTestingFileHiveMetastore(hiveDir);
    HiveIdentity identity = new HiveIdentity(SESSION);
    metastore.createDatabase(identity, Database.builder().setDatabaseName("tpch").setOwnerName("public").setOwnerType(PrincipalType.ROLE).build());
    HiveConnectorFactory hiveConnectorFactory = new HiveConnectorFactory("hive", HiveBenchmarkQueryRunner.class.getClassLoader(), Optional.of(metastore));
    Map<String, String> hiveCatalogConfig = ImmutableMap.<String, String>builder().put("hive.max-split-size", "10GB").build();
    localQueryRunner.createCatalog("hive", hiveConnectorFactory, hiveCatalogConfig);
    localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
    localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
    return localQueryRunner;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) FileHiveMetastore.createTestingFileHiveMetastore(io.prestosql.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore) HiveMetastore(io.prestosql.plugin.hive.metastore.HiveMetastore) File(java.io.File) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) HiveIdentity(io.prestosql.plugin.hive.authentication.HiveIdentity) Session(io.prestosql.Session)

Example 17 with LocalQueryRunner

use of io.prestosql.testing.LocalQueryRunner in project boostkit-bigdata by kunpengcompute.

the class HiveBenchmarkQueryRunner method main.

public static void main(String[] args) throws IOException {
    String outputDirectory = requireNonNull(System.getProperty("outputDirectory"), "Must specify -DoutputDirectory=...");
    File tempDir = createTempDirectory("HiveBenchmarkQueryRunner").toFile();
    try (LocalQueryRunner localQueryRunner = createLocalQueryRunner(tempDir)) {
        new BenchmarkSuite(localQueryRunner, outputDirectory).runAllBenchmarks();
    } finally {
        deleteRecursively(tempDir.toPath(), ALLOW_INSECURE);
    }
}
Also used : File(java.io.File) BenchmarkSuite(io.prestosql.benchmark.BenchmarkSuite) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner)

Example 18 with LocalQueryRunner

use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.

the class TestMLQueries method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    localQueryRunner.installPlugin(new MLPlugin());
    return localQueryRunner;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Session(io.prestosql.Session)

Example 19 with LocalQueryRunner

use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.

the class LocalAtopQueryRunner method createQueryRunner.

public static LocalQueryRunner createQueryRunner(Map<String, String> catalogProperties, Class<? extends AtopFactory> factoryClass) {
    Session session = testSessionBuilder().setCatalog("atop").setSchema("default").setTimeZoneKey(TimeZoneKey.getTimeZoneKey(TimeZone.getDefault().getID())).build();
    LocalQueryRunner queryRunner = new LocalQueryRunner(session);
    try {
        AtopConnectorFactory connectorFactory = new AtopConnectorFactory(factoryClass, LocalAtopQueryRunner.class.getClassLoader());
        ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder().putAll(catalogProperties).put("atop.max-history-days", "1");
        queryRunner.createCatalog("atop", connectorFactory, properties.build());
        return queryRunner;
    } catch (Exception e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) ImmutableMap(com.google.common.collect.ImmutableMap) Session(io.prestosql.Session)

Example 20 with LocalQueryRunner

use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.

the class TestCostCalculator method setUp.

@BeforeClass
public void setUp() {
    TaskCountEstimator taskCountEstimator = new TaskCountEstimator(() -> NUMBER_OF_NODES);
    costCalculatorUsingExchanges = new CostCalculatorUsingExchanges(taskCountEstimator);
    costCalculatorWithEstimatedExchanges = new CostCalculatorWithEstimatedExchanges(costCalculatorUsingExchanges, taskCountEstimator);
    session = testSessionBuilder().setCatalog("tpch").build();
    localQueryRunner = new LocalQueryRunner(session);
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(), ImmutableMap.of());
    metadata = createTestMetadataManager();
    planFragmenter = new PlanFragmenter(localQueryRunner.getMetadata(), localQueryRunner.getNodePartitioningManager(), new QueryManagerConfig());
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) PlanFragmenter(io.prestosql.sql.planner.PlanFragmenter) QueryManagerConfig(io.prestosql.execution.QueryManagerConfig) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

LocalQueryRunner (io.prestosql.testing.LocalQueryRunner)29 TpchConnectorFactory (io.prestosql.plugin.tpch.TpchConnectorFactory)20 Session (io.prestosql.Session)15 BeforeClass (org.testng.annotations.BeforeClass)9 File (java.io.File)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)3 TestingSession.testSessionBuilder (io.prestosql.testing.TestingSession.testSessionBuilder)3 Test (org.testng.annotations.Test)3 ImmutableList (com.google.common.collect.ImmutableList)2 HetuFileSystemClientPlugin (io.hetu.core.filesystem.HetuFileSystemClientPlugin)2 BenchmarkQueryRunner.createLocalQueryRunner (io.prestosql.benchmark.BenchmarkQueryRunner.createLocalQueryRunner)2 BenchmarkSuite (io.prestosql.benchmark.BenchmarkSuite)2 MockConnectorFactory (io.prestosql.connector.MockConnectorFactory)2 SessionPropertyManager (io.prestosql.metadata.SessionPropertyManager)2 HiveIdentity (io.prestosql.plugin.hive.authentication.HiveIdentity)2 HiveMetastore (io.prestosql.plugin.hive.metastore.HiveMetastore)2 FileHiveMetastore.createTestingFileHiveMetastore (io.prestosql.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore)2 MemoryConnectorFactory (io.prestosql.plugin.memory.MemoryConnectorFactory)2 TINY_SCHEMA_NAME (io.prestosql.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME)2