Search in sources :

Example 6 with LocalQueryRunner

use of io.trino.testing.LocalQueryRunner in project trino by trinodb.

the class TestTableScanNodePartitioning method createLocalQueryRunner.

@Override
protected LocalQueryRunner createLocalQueryRunner() {
    Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog(MOCK_CATALOG).setSchema(TEST_SCHEMA);
    LocalQueryRunner queryRunner = LocalQueryRunner.builder(sessionBuilder.build()).withNodeCountForStats(10).build();
    queryRunner.createCatalog(MOCK_CATALOG, createMockFactory(), ImmutableMap.of());
    queryRunner.getNodePartitioningManager().addPartitioningProvider(new CatalogName(MOCK_CATALOG), new TestPartitioningProvider(new InMemoryNodeManager()));
    return queryRunner;
}
Also used : CatalogName(io.trino.connector.CatalogName) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session) ConnectorSession(io.trino.spi.connector.ConnectorSession) InMemoryNodeManager(io.trino.metadata.InMemoryNodeManager)

Example 7 with LocalQueryRunner

use of io.trino.testing.LocalQueryRunner in project trino by trinodb.

the class TestHivePlans method createQueryRunner.

protected LocalQueryRunner createQueryRunner(Session session, HiveMetastore metastore) {
    LocalQueryRunner queryRunner = LocalQueryRunner.create(session);
    queryRunner.createCatalog(HIVE_CATALOG_NAME, new TestingHiveConnectorFactory(metastore), Map.of("hive.max-partitions-per-scan", "5"));
    return queryRunner;
}
Also used : TestingHiveConnectorFactory(io.trino.plugin.hive.TestingHiveConnectorFactory) LocalQueryRunner(io.trino.testing.LocalQueryRunner)

Example 8 with LocalQueryRunner

use of io.trino.testing.LocalQueryRunner in project trino by trinodb.

the class TestHiveProjectionPushdownIntoTableScan method createLocalQueryRunner.

@Override
protected LocalQueryRunner createLocalQueryRunner() {
    baseDir = Files.createTempDir();
    HdfsConfig config = new HdfsConfig();
    HdfsConfiguration configuration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(config), ImmutableSet.of());
    HdfsEnvironment environment = new HdfsEnvironment(configuration, config, new NoHdfsAuthentication());
    HiveMetastore metastore = new FileHiveMetastore(new NodeVersion("test_version"), environment, new MetastoreConfig(), new FileHiveMetastoreConfig().setCatalogDirectory(baseDir.toURI().toString()).setMetastoreUser("test"));
    Database database = Database.builder().setDatabaseName(SCHEMA_NAME).setOwnerName(Optional.of("public")).setOwnerType(Optional.of(PrincipalType.ROLE)).build();
    metastore.createDatabase(database);
    LocalQueryRunner queryRunner = LocalQueryRunner.create(HIVE_SESSION);
    queryRunner.createCatalog(HIVE_CATALOG_NAME, new TestingHiveConnectorFactory(metastore), ImmutableMap.of());
    return queryRunner;
}
Also used : HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) 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) LocalQueryRunner(io.trino.testing.LocalQueryRunner) 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) TestingHiveConnectorFactory(io.trino.plugin.hive.TestingHiveConnectorFactory) Database(io.trino.plugin.hive.metastore.Database)

Example 9 with LocalQueryRunner

use of io.trino.testing.LocalQueryRunner in project trino by trinodb.

the class TestConnectorEventListener method testConnectorWithoutEventListener.

@Test
public void testConnectorWithoutEventListener() {
    LocalQueryRunner queryRunner = LocalQueryRunner.builder(testSessionBuilder().build()).build();
    queryRunner.loadEventListeners();
    assertThatCode(() -> queryRunner.execute("SELECT 1")).doesNotThrowAnyException();
}
Also used : LocalQueryRunner(io.trino.testing.LocalQueryRunner) Test(org.testng.annotations.Test)

Example 10 with LocalQueryRunner

use of io.trino.testing.LocalQueryRunner in project trino by trinodb.

the class TestConnectorEventListener method testConnectorWithEventListener.

@Test
public void testConnectorWithEventListener() {
    MockEventListenerFactory listenerFactory = new MockEventListenerFactory();
    LocalQueryRunner queryRunner = LocalQueryRunner.builder(testSessionBuilder().build()).build();
    queryRunner.createCatalog("event_listening", MockConnectorFactory.builder().withEventListener(listenerFactory).build(), ImmutableMap.of());
    queryRunner.loadEventListeners();
    assertThat(listenerFactory.getEventListenerInvocationCounter).hasValue(1);
}
Also used : LocalQueryRunner(io.trino.testing.LocalQueryRunner) Test(org.testng.annotations.Test)

Aggregations

LocalQueryRunner (io.trino.testing.LocalQueryRunner)66 Session (io.trino.Session)28 TpchConnectorFactory (io.trino.plugin.tpch.TpchConnectorFactory)25 Test (org.testng.annotations.Test)22 ImmutableMap (com.google.common.collect.ImmutableMap)12 SchemaTableName (io.trino.spi.connector.SchemaTableName)12 ImmutableList (com.google.common.collect.ImmutableList)11 MockConnectorFactory (io.trino.connector.MockConnectorFactory)11 Optional (java.util.Optional)11 CatalogName (io.trino.connector.CatalogName)9 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)9 MockConnectorTableHandle (io.trino.connector.MockConnectorTableHandle)8 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)8 CatalogSchemaTableName (io.trino.spi.connector.CatalogSchemaTableName)7 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)7 TrinoException (io.trino.spi.TrinoException)6 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 ColumnHandle (io.trino.spi.connector.ColumnHandle)5 List (java.util.List)5