Search in sources :

Example 11 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestIcebergMetadataListing method createQueryRunner.

@Override
protected DistributedQueryRunner createQueryRunner() throws Exception {
    Session session = testSessionBuilder().setIdentity(Identity.forUser("hive").withConnectorRole("hive", new SelectedRole(ROLE, Optional.of("admin"))).build()).build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).build();
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    metastore = new FileHiveMetastore(new NodeVersion("test_version"), hdfsEnvironment, new MetastoreConfig(), new FileHiveMetastoreConfig().setCatalogDirectory(baseDir.toURI().toString()).setMetastoreUser("test"));
    queryRunner.installPlugin(new TestingIcebergPlugin(Optional.of(metastore), Optional.empty(), EMPTY_MODULE));
    queryRunner.createCatalog("iceberg", "iceberg");
    queryRunner.installPlugin(new TestingHivePlugin(metastore));
    queryRunner.createCatalog("hive", "hive", ImmutableMap.of("hive.security", "sql-standard"));
    return queryRunner;
}
Also used : HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) SelectedRole(io.trino.spi.security.SelectedRole) TestingHivePlugin(io.trino.plugin.hive.TestingHivePlugin) HdfsConfig(io.trino.plugin.hive.HdfsConfig) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) NodeVersion(io.trino.plugin.hive.NodeVersion) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) File(java.io.File) Session(io.trino.Session)

Example 12 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestIcebergMetastoreAccessOperations method createQueryRunner.

@Override
protected DistributedQueryRunner createQueryRunner() throws Exception {
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(TEST_SESSION).build();
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    HiveMetastore hiveMetastore = new FileHiveMetastore(new NodeVersion("testversion"), hdfsEnvironment, new MetastoreConfig(), new FileHiveMetastoreConfig().setCatalogDirectory(baseDir.toURI().toString()).setMetastoreUser("test"));
    metastore = new CountingAccessFileHiveMetastore(hiveMetastore);
    queryRunner.installPlugin(new TestingIcebergPlugin(Optional.of(metastore), Optional.empty(), EMPTY_MODULE));
    queryRunner.createCatalog("iceberg", "iceberg");
    queryRunner.execute("CREATE SCHEMA test_schema");
    return queryRunner;
}
Also used : HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) HdfsConfig(io.trino.plugin.hive.HdfsConfig) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) NodeVersion(io.trino.plugin.hive.NodeVersion) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) File(java.io.File)

Example 13 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class FileHiveMetastore method createTestingFileHiveMetastore.

@VisibleForTesting
public static FileHiveMetastore createTestingFileHiveMetastore(File catalogDirectory) {
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    return new FileHiveMetastore(new NodeVersion("testversion"), hdfsEnvironment, new MetastoreConfig(), new FileHiveMetastoreConfig().setCatalogDirectory(catalogDirectory.toURI().toString()).setMetastoreUser("test"));
}
Also used : NodeVersion(io.trino.plugin.hive.NodeVersion) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) HdfsConfig(io.trino.plugin.hive.HdfsConfig) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 14 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestDeltaLakePageSink method createPageSink.

private static ConnectorPageSink createPageSink(Path outputPath, DeltaLakeWriterStats stats) {
    HiveTransactionHandle transaction = new HiveTransactionHandle(false);
    DeltaLakeConfig deltaLakeConfig = new DeltaLakeConfig();
    DeltaLakeOutputTableHandle tableHandle = new DeltaLakeOutputTableHandle(SCHEMA_NAME, TABLE_NAME, getColumnHandles(), outputPath.toString(), Optional.of(deltaLakeConfig.getDefaultCheckpointWritingInterval()), true);
    DeltaLakePageSinkProvider provider = new DeltaLakePageSinkProvider(new GroupByHashPageIndexerFactory(new JoinCompiler(new TypeOperators()), new BlockTypeOperators()), HDFS_ENVIRONMENT, JsonCodec.jsonCodec(DataFileInfo.class), stats, deltaLakeConfig, new TestingTypeManager(), new NodeVersion("test-version"));
    return provider.createPageSink(transaction, SESSION, tableHandle);
}
Also used : NodeVersion(io.trino.plugin.hive.NodeVersion) JoinCompiler(io.trino.sql.gen.JoinCompiler) BlockTypeOperators(io.trino.type.BlockTypeOperators) HiveTransactionHandle(io.trino.plugin.hive.HiveTransactionHandle) GroupByHashPageIndexerFactory(io.trino.operator.GroupByHashPageIndexerFactory) TestingTypeManager(io.trino.spi.type.TestingTypeManager) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators)

Example 15 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestDeltaLakeGlueMetastore method setUp.

@BeforeClass
public void setUp() {
    tempDir = Files.createTempDir();
    String temporaryLocation = tempDir.toURI().toString();
    Map<String, String> config = ImmutableMap.<String, String>builder().put("hive.metastore", "glue").put("delta.hide-non-delta-lake-tables", "true").buildOrThrow();
    Bootstrap app = new Bootstrap(// connector dependencies
    new JsonModule(), binder -> {
        ConnectorContext context = new TestingConnectorContext();
        binder.bind(CatalogName.class).toInstance(new CatalogName("test"));
        binder.bind(TypeManager.class).toInstance(context.getTypeManager());
        binder.bind(NodeManager.class).toInstance(context.getNodeManager());
        binder.bind(PageIndexerFactory.class).toInstance(context.getPageIndexerFactory());
        binder.bind(NodeVersion.class).toInstance(new NodeVersion("test_version"));
    }, // connector modules
    new DeltaLakeMetastoreModule(), new DeltaLakeModule(), // test setup
    binder -> {
        binder.bind(HdfsEnvironment.class).toInstance(HDFS_ENVIRONMENT);
    });
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    metastoreClient = injector.getInstance(GlueHiveMetastore.class);
    metadataFactory = injector.getInstance(DeltaLakeMetadataFactory.class);
    session = TestingConnectorSession.builder().setPropertyMetadata(injector.getInstance(DeltaLakeSessionProperties.class).getSessionProperties()).build();
    databaseName = "test_delta_glue" + randomName();
    metastoreClient.createDatabase(Database.builder().setDatabaseName(databaseName).setOwnerName(Optional.of("public")).setOwnerType(Optional.of(ROLE)).setLocation(Optional.of(temporaryLocation)).build());
}
Also used : DeltaLakeModule(io.trino.plugin.deltalake.DeltaLakeModule) TestingConnectorContext(io.trino.testing.TestingConnectorContext) DeltaLakeMetadataFactory(io.trino.plugin.deltalake.DeltaLakeMetadataFactory) JsonModule(io.airlift.json.JsonModule) PageIndexerFactory(io.trino.spi.PageIndexerFactory) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) GlueHiveMetastore(io.trino.plugin.hive.metastore.glue.GlueHiveMetastore) NodeVersion(io.trino.plugin.hive.NodeVersion) NodeManager(io.trino.spi.NodeManager) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) ConnectorContext(io.trino.spi.connector.ConnectorContext) TestingConnectorContext(io.trino.testing.TestingConnectorContext) DeltaLakeMetastoreModule(io.trino.plugin.deltalake.metastore.DeltaLakeMetastoreModule) Bootstrap(io.airlift.bootstrap.Bootstrap) TypeManager(io.trino.spi.type.TypeManager) CatalogName(io.trino.plugin.base.CatalogName) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

NodeVersion (io.trino.plugin.hive.NodeVersion)17 HdfsEnvironment (io.trino.plugin.hive.HdfsEnvironment)13 HdfsConfig (io.trino.plugin.hive.HdfsConfig)11 HdfsConfiguration (io.trino.plugin.hive.HdfsConfiguration)11 HdfsConfigurationInitializer (io.trino.plugin.hive.HdfsConfigurationInitializer)11 HiveHdfsConfiguration (io.trino.plugin.hive.HiveHdfsConfiguration)11 NoHdfsAuthentication (io.trino.plugin.hive.authentication.NoHdfsAuthentication)11 MetastoreConfig (io.trino.plugin.hive.metastore.MetastoreConfig)11 FileHiveMetastore (io.trino.plugin.hive.metastore.file.FileHiveMetastore)10 FileHiveMetastoreConfig (io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig)10 CatalogName (io.trino.plugin.base.CatalogName)6 HiveMetastore (io.trino.plugin.hive.metastore.HiveMetastore)6 TypeManager (io.trino.spi.type.TypeManager)5 Injector (com.google.inject.Injector)4 Bootstrap (io.airlift.bootstrap.Bootstrap)4 JsonModule (io.airlift.json.JsonModule)4 NodeManager (io.trino.spi.NodeManager)4 PageIndexerFactory (io.trino.spi.PageIndexerFactory)4 ConnectorContext (io.trino.spi.connector.ConnectorContext)4 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)4