Search in sources :

Example 1 with FileHiveMetastore

use of com.facebook.presto.hive.metastore.file.FileHiveMetastore in project presto by prestodb.

the class HiveQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Iterable<TpchTable<?>> tables, Map<String, String> extraProperties, String security, Map<String, String> extraHiveProperties) throws Exception {
    assertEquals(DateTimeZone.getDefault(), TIME_ZONE, "Timezone not configured correctly. Add -Duser.timezone=Asia/Katmandu to your JVM arguments");
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession(), 4, extraProperties);
    try {
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("hive_data").toFile();
        HiveClientConfig hiveClientConfig = new HiveClientConfig();
        HiveS3Config s3Config = new HiveS3Config();
        HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationUpdater(hiveClientConfig, s3Config));
        HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hiveClientConfig, new NoHdfsAuthentication());
        FileHiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
        metastore.createDatabase(createDatabaseMetastoreObject(TPCH_SCHEMA));
        metastore.createDatabase(createDatabaseMetastoreObject(TPCH_BUCKETED_SCHEMA));
        queryRunner.installPlugin(new HivePlugin(HIVE_CATALOG, metastore));
        Map<String, String> hiveProperties = ImmutableMap.<String, String>builder().putAll(extraHiveProperties).put("hive.metastore.uri", "thrift://localhost:8080").put("hive.time-zone", TIME_ZONE.getID()).put("hive.security", security).build();
        Map<String, String> hiveBucketedProperties = ImmutableMap.<String, String>builder().putAll(hiveProperties).put("hive.max-initial-split-size", // so that each bucket has multiple splits
        "10kB").put("hive.max-split-size", // so that each bucket has multiple splits
        "10kB").put("hive.storage-format", // so that there's no minimum split size for the file
        "TEXTFILE").put("hive.compression-codec", // so that the file is splittable
        "NONE").build();
        queryRunner.createCatalog(HIVE_CATALOG, HIVE_CATALOG, hiveProperties);
        queryRunner.createCatalog(HIVE_BUCKETED_CATALOG, HIVE_CATALOG, hiveBucketedProperties);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        copyTpchTablesBucketed(queryRunner, "tpch", TINY_SCHEMA_NAME, createBucketedSession(), tables);
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication) FileHiveMetastore(com.facebook.presto.hive.metastore.file.FileHiveMetastore) File(java.io.File)

Example 2 with FileHiveMetastore

use of com.facebook.presto.hive.metastore.file.FileHiveMetastore in project presto by prestodb.

the class TestHiveClientFileMetastore method createMetastore.

@Override
protected ExtendedHiveMetastore createMetastore(File tempDir) {
    File baseDir = new File(tempDir, "metastore");
    HiveClientConfig hiveConfig = new HiveClientConfig();
    HdfsConfigurationUpdater updator = new HdfsConfigurationUpdater(hiveConfig, new HiveS3Config());
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(updator);
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hiveConfig, new NoHdfsAuthentication());
    return new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test");
}
Also used : FileHiveMetastore(com.facebook.presto.hive.metastore.file.FileHiveMetastore) File(java.io.File) NoHdfsAuthentication(com.facebook.presto.hive.authentication.NoHdfsAuthentication)

Aggregations

NoHdfsAuthentication (com.facebook.presto.hive.authentication.NoHdfsAuthentication)2 FileHiveMetastore (com.facebook.presto.hive.metastore.file.FileHiveMetastore)2 File (java.io.File)2 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)1 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)1