Search in sources :

Example 6 with HetuMetastorePlugin

use of io.hetu.core.metastore.HetuMetastorePlugin in project hetu-core by openlookeng.

the class TestDynamicHiveScalarFunction method setUpClass.

@BeforeClass
public void setUpClass() throws Exception {
    RecognizedFunctions.addRecognizedFunction("io.hetu.core.hive.dynamicfunctions.examples.udf.ListStringUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.TimeOutUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.BooleanUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.MapDoubleUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.DoubleUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.EvaluateOverloadUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.ShortUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.ArrayListDoubleUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.FloatWrapperUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.LongUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.IntThreeArgsUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.IntUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.IntTwoArgsUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.IntFiveArgsUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.MapIntUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.MapStringUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.EmptyParameterUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.IntWrapperUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.IntSixArgsUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.IntFourArgsUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.BooleanWrappperUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.ListIntUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.LongWrapperUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.ByteWrapperUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.ListDoubleUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.ShortWrapperUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.ByteUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.DoubleWrapperUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.FloatUDF", "io.hetu.core.hive.dynamicfunctions.examples.udf.NullInputUDF");
    try {
        queryRunner = DistributedQueryRunner.builder(testSessionBuilder().setCatalog("memory").setSchema("default").build()).setNodeCount(1).build();
        TempFolder folder = new TempFolder();
        folder.create();
        Runtime.getRuntime().addShutdownHook(new Thread(folder::close));
        // need dep on hetu-filesystem
        queryRunner.installPlugin(new HetuFileSystemClientPlugin());
        // need dep on hetu-metastore
        queryRunner.installPlugin(new HetuMetastorePlugin());
        queryRunner.installPlugin(new MemoryPlugin());
        HashMap<String, String> metastoreConfig = new HashMap<>();
        metastoreConfig.put("hetu.metastore.type", "hetufilesystem");
        metastoreConfig.put("hetu.metastore.hetufilesystem.profile-name", "default");
        metastoreConfig.put("hetu.metastore.hetufilesystem.path", folder.newFolder("metastore").getAbsolutePath());
        queryRunner.getCoordinator().loadMetastore(metastoreConfig);
        queryRunner.createCatalog("memory", "memory", ImmutableMap.of("memory.spill-path", folder.newFolder("memory-connector").getAbsolutePath()));
        createBooleanTable();
        createByteTable();
        createShortTable();
        createIntTable();
        createLongTable();
        createFloatTable();
        createDoubleTable();
        createListTable();
        createMapTable();
        createMultipleParameterTable();
        createEvaluateOverloadTable();
    } catch (Exception e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : HetuFileSystemClientPlugin(io.hetu.core.filesystem.HetuFileSystemClientPlugin) HetuMetastorePlugin(io.hetu.core.metastore.HetuMetastorePlugin) HashMap(java.util.HashMap) TempFolder(io.hetu.core.common.filesystem.TempFolder) MemoryPlugin(io.prestosql.plugin.memory.MemoryPlugin) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with HetuMetastorePlugin

use of io.hetu.core.metastore.HetuMetastorePlugin in project hetu-core by openlookeng.

the class VdmQueryRunner method createVdmQueryRunner.

public static QueryRunner createVdmQueryRunner(String jdbcUrl, Map<String, String> connectorProperties, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        File directory = new File("");
        String courseFile = directory.getCanonicalPath();
        System.setProperty("config", courseFile + "/etc/");
        String configDir = System.getProperty("config");
        String hetumetastoreConfig = configDir + "hetu-metastore.properties";
        File file = new File(configDir);
        if (!file.exists()) {
            file.mkdirs();
        }
        File file2 = new File(configDir, "hetu-metastore.properties");
        if (!file2.exists()) {
            try {
                file2.createNewFile();
            } catch (IOException e) {
                LOG.info("Error message: " + e.getStackTrace());
            }
        }
        try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(hetumetastoreConfig))) {
            bufferedWriter.write("hetu.metastore.db.url = " + jdbcUrl);
            bufferedWriter.write("\n");
            bufferedWriter.write("hetu.metastore.type = jdbc\n");
            bufferedWriter.write("hetu.metastore.db.user = user\n");
            bufferedWriter.write("hetu.metastore.db.password = testpass\n");
            bufferedWriter.write("hetu.metastore.cache.ttl = 0s");
        }
        queryRunner = DistributedQueryRunner.builder(createSession()).setNodeCount(1).setExtraProperties(ImmutableMap.of()).setCoordinatorProperties(ImmutableMap.of()).setParserOptions(DEFAULT_SQL_PARSER_OPTIONS).setEnvironment("vdmtest").setBaseDataDir(Optional.empty()).build();
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.installPlugin(new VdmPlugin());
        queryRunner.installPlugin(new HetuMetastorePlugin());
        queryRunner.getCoordinator().loadMetastore();
        queryRunner.createCatalog("tpch", "tpch");
        queryRunner.createCatalog("vdm", "vdm", ImmutableMap.of("vdm.metadata-cache-enabled", "false"));
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) HetuMetastorePlugin(io.hetu.core.metastore.HetuMetastorePlugin) TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 8 with HetuMetastorePlugin

use of io.hetu.core.metastore.HetuMetastorePlugin in project hetu-core by openlookeng.

the class MemoryQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(int nodes, Map<String, String> extraProperties, Map<String, String> memoryProperties, Boolean createTpchTables) throws Exception {
    Session session = testSessionBuilder().setCatalog(CATALOG).setSchema("default").build();
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, nodes, extraProperties);
    Runtime.getRuntime().addShutdownHook(new Thread(queryRunner::close));
    try {
        queryRunner.installPlugin(new HetuFileSystemClientPlugin());
        queryRunner.installPlugin(new HetuMetastorePlugin());
        TempFolder metastoreFolder = new TempFolder().create();
        Runtime.getRuntime().addShutdownHook(new Thread(metastoreFolder::close));
        Map<String, String> metastoreConfig = new HashMap<>();
        metastoreConfig.put("hetu.metastore.type", "hetufilesystem");
        metastoreConfig.put("hetu.metastore.hetufilesystem.profile-name", "default");
        metastoreConfig.put("hetu.metastore.hetufilesystem.path", metastoreFolder.newFolder("metastore").getAbsolutePath());
        queryRunner.getServers().forEach(server -> {
            try {
                server.loadMetastore(new HashMap<>(metastoreConfig));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        queryRunner.installPlugin(new MemoryPlugin());
        queryRunner.getServers().forEach(server -> {
            try {
                TempFolder folder = new TempFolder();
                folder.create();
                Runtime.getRuntime().addShutdownHook(new Thread(folder::close));
                // create memory catalog with custom memory properties
                server.createCatalog(CATALOG, "memory", createConfig(folder, memoryProperties));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of());
        queryRunner.installPlugin(new TpcdsPlugin());
        queryRunner.createCatalog("tpcds", "tpcds", ImmutableMap.of());
        if (createTpchTables) {
            copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, session, TpchTable.getTables());
        }
        return queryRunner;
    } catch (Exception e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : HetuFileSystemClientPlugin(io.hetu.core.filesystem.HetuFileSystemClientPlugin) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) HashMap(java.util.HashMap) TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin) IOException(java.io.IOException) HetuMetastorePlugin(io.hetu.core.metastore.HetuMetastorePlugin) TempFolder(io.hetu.core.common.filesystem.TempFolder) TpcdsPlugin(io.prestosql.plugin.tpcds.TpcdsPlugin) Session(io.prestosql.Session)

Aggregations

HetuMetastorePlugin (io.hetu.core.metastore.HetuMetastorePlugin)8 HashMap (java.util.HashMap)6 HetuFileSystemClientPlugin (io.hetu.core.filesystem.HetuFileSystemClientPlugin)5 DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)5 TempFolder (io.hetu.core.common.filesystem.TempFolder)4 TpchPlugin (io.prestosql.plugin.tpch.TpchPlugin)4 File (java.io.File)4 IOException (java.io.IOException)4 HiveIdentity (io.prestosql.plugin.hive.authentication.HiveIdentity)3 BufferedWriter (java.io.BufferedWriter)3 FileWriter (java.io.FileWriter)3 StarTreePlugin (io.hetu.core.cube.startree.StarTreePlugin)2 Session (io.prestosql.Session)2 NoHdfsAuthentication (io.prestosql.plugin.hive.authentication.NoHdfsAuthentication)2 FileHiveMetastore (io.prestosql.plugin.hive.metastore.file.FileHiveMetastore)2 MemoryPlugin (io.prestosql.plugin.memory.MemoryPlugin)2 SelectedRole (io.prestosql.spi.security.SelectedRole)2 BeforeClass (org.testng.annotations.BeforeClass)2 HiveHadoop2Plugin (io.prestosql.plugin.hive.HiveHadoop2Plugin)1 HivePlugin (io.prestosql.plugin.hive.HivePlugin)1