Search in sources :

Example 1 with HiveHadoop2Plugin

use of com.facebook.presto.hive.HiveHadoop2Plugin in project presto by prestodb.

the class TestPrestoSparkLauncherIntegrationSmokeTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    assertEquals(DateTimeZone.getDefault(), TIME_ZONE, "Timezone not configured correctly. Add -Duser.timezone=America/Bahia_Banderas to your JVM arguments");
    // the default temporary directory location on MacOS is not sharable to docker
    tempDir = new File("/tmp", randomUUID().toString());
    createDirectories(tempDir.toPath());
    sparkWorkDirectory = new File(tempDir, "work");
    createDirectories(sparkWorkDirectory.toPath());
    File composeYaml = extractResource("docker-compose.yml", tempDir);
    dockerCompose = new DockerCompose(composeYaml);
    dockerCompose.verifyInstallation();
    dockerCompose.pull();
    composeProcess = dockerCompose.up(ImmutableMap.of("spark-master", 1, "spark-worker", 2, "hadoop-master", 1));
    Session session = testSessionBuilder().setCatalog("hive").setSchema("default").build();
    localQueryRunner = new LocalQueryRunner(session);
    HiveHadoop2Plugin plugin = new HiveHadoop2Plugin();
    ConnectorFactory hiveConnectorFactory = getOnlyElement(plugin.getConnectorFactories());
    addStaticResolution("hadoop-master", "127.0.0.1");
    String hadoopMasterAddress = dockerCompose.getContainerAddress("hadoop-master");
    // datanode is accessed via the internal docker IP address that is not accessible from the host
    addStaticResolution(hadoopMasterAddress, "127.0.0.1");
    localQueryRunner.createCatalog("hive", hiveConnectorFactory, ImmutableMap.of("hive.metastore.uri", "thrift://127.0.0.1:9083", "hive.time-zone", TIME_ZONE.getID(), "hive.experimental-optimized-partition-update-serialization-enabled", "true"));
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(), ImmutableMap.of());
    // it may take some time for the docker container to start
    ensureHiveIsRunning(localQueryRunner, new Duration(10, MINUTES));
    importTables(localQueryRunner, "lineitem", "orders");
    importTablesBucketed(localQueryRunner, ImmutableList.of("orderkey"), "lineitem", "orders");
    File projectRoot = resolveProjectRoot();
    prestoLauncher = resolveFile(new File(projectRoot, "presto-spark-launcher/target"), Pattern.compile("presto-spark-launcher-[\\d\\.]+(-SNAPSHOT)?\\.jar"));
    logPackageInfo(prestoLauncher);
    prestoPackage = resolveFile(new File(projectRoot, "presto-spark-package/target"), Pattern.compile("presto-spark-package-.+\\.tar\\.gz"));
    logPackageInfo(prestoPackage);
    configProperties = new File(tempDir, "config.properties");
    storeProperties(configProperties, ImmutableMap.of("query.hash-partition-count", "10"));
    catalogDirectory = new File(tempDir, "catalogs");
    createDirectories(catalogDirectory.toPath());
    storeProperties(new File(catalogDirectory, "hive.properties"), ImmutableMap.of("connector.name", "hive-hadoop2", "hive.metastore.uri", "thrift://hadoop-master:9083", // the getnetgrent dependency is missing
    "hive.dfs.require-hadoop-native", "false", "hive.time-zone", TIME_ZONE.getID()));
    storeProperties(new File(catalogDirectory, "tpch.properties"), ImmutableMap.of("connector.name", "tpch", "tpch.splits-per-node", "4", "tpch.partitioning-enabled", "false"));
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) HiveHadoop2Plugin(com.facebook.presto.hive.HiveHadoop2Plugin) Duration(io.airlift.units.Duration) File(java.io.File) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with HiveHadoop2Plugin

use of com.facebook.presto.hive.HiveHadoop2Plugin in project presto by prestodb.

the class TestJdbcConnection method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    Logging.initialize();
    Module systemTables = binder -> newSetBinder(binder, SystemTable.class).addBinding().to(ExtraCredentialsSystemTable.class).in(Scopes.SINGLETON);
    server = new TestingPrestoServer(ImmutableList.of(systemTables));
    server.installPlugin(new HiveHadoop2Plugin());
    server.createCatalog("hive", "hive-hadoop2", ImmutableMap.<String, String>builder().put("hive.metastore", "file").put("hive.metastore.catalog.dir", server.getBaseDataDir().resolve("hive").toFile().toURI().toString()).put("hive.security", "sql-standard").build());
    try (Connection connection = createConnection();
        Statement statement = connection.createStatement()) {
        statement.execute("SET ROLE admin");
        statement.execute("CREATE SCHEMA default");
        statement.execute("CREATE SCHEMA fruit");
    }
}
Also used : Module(com.google.inject.Module) Connection(java.sql.Connection) DataProvider(org.testng.annotations.DataProvider) VarcharType.createUnboundedVarcharType(com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) InMemoryRecordSet(com.facebook.presto.spi.InMemoryRecordSet) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) SQLException(java.sql.SQLException) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) HiveHadoop2Plugin(com.facebook.presto.hive.HiveHadoop2Plugin) ResultSet(java.sql.ResultSet) Map(java.util.Map) Multibinder.newSetBinder(com.google.inject.multibindings.Multibinder.newSetBinder) SystemTable(com.facebook.presto.spi.SystemTable) Assert.assertFalse(org.testng.Assert.assertFalse) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) AfterClass(org.testng.annotations.AfterClass) ImmutableSet(com.google.common.collect.ImmutableSet) Properties(java.util.Properties) ALL_NODES(com.facebook.presto.spi.SystemTable.Distribution.ALL_NODES) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) Set(java.util.Set) TableMetadataBuilder.tableMetadataBuilder(com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) Assert.assertNotNull(org.testng.Assert.assertNotNull) PreparedStatement(java.sql.PreparedStatement) Scopes(com.google.inject.Scopes) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) StandardCharsets(java.nio.charset.StandardCharsets) String.format(java.lang.String.format) TestPrestoDriver.closeQuietly(com.facebook.presto.jdbc.TestPrestoDriver.closeQuietly) ConnectorSession(com.facebook.presto.spi.ConnectorSession) RecordCursor(com.facebook.presto.spi.RecordCursor) URLEncoder(java.net.URLEncoder) List(java.util.List) Logging(com.facebook.airlift.log.Logging) Statement(java.sql.Statement) Assert.assertTrue(org.testng.Assert.assertTrue) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DriverManager(java.sql.DriverManager) Joiner(com.google.common.base.Joiner) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) Connection(java.sql.Connection) HiveHadoop2Plugin(com.facebook.presto.hive.HiveHadoop2Plugin) SystemTable(com.facebook.presto.spi.SystemTable) Module(com.google.inject.Module) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

HiveHadoop2Plugin (com.facebook.presto.hive.HiveHadoop2Plugin)2 Logging (com.facebook.airlift.log.Logging)1 Session (com.facebook.presto.Session)1 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)1 VarcharType.createUnboundedVarcharType (com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType)1 TestPrestoDriver.closeQuietly (com.facebook.presto.jdbc.TestPrestoDriver.closeQuietly)1 TableMetadataBuilder.tableMetadataBuilder (com.facebook.presto.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder)1 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)1 ConnectorSession (com.facebook.presto.spi.ConnectorSession)1 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)1 InMemoryRecordSet (com.facebook.presto.spi.InMemoryRecordSet)1 RecordCursor (com.facebook.presto.spi.RecordCursor)1 SchemaTableName (com.facebook.presto.spi.SchemaTableName)1 SystemTable (com.facebook.presto.spi.SystemTable)1 ALL_NODES (com.facebook.presto.spi.SystemTable.Distribution.ALL_NODES)1 ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)1 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)1 LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)1 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)1 Joiner (com.google.common.base.Joiner)1