Search in sources :

Example 1 with Plugin

use of io.trino.spi.Plugin in project trino by trinodb.

the class TestDeltaLakePlugin method testThriftMetastore.

@Test
public void testThriftMetastore() {
    Plugin plugin = new TestingDeltaLakePlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("hive.metastore", "thrift", "hive.metastore.uri", "thrift://foo:1234"), new TestingConnectorContext()).shutdown();
    assertThatThrownBy(() -> factory.create("test", ImmutableMap.of("hive.metastore", "thrift", "hive.metastore.uri", "thrift://foo:1234", "delta.hide-non-delta-lake-tables", "true"), new TestingConnectorContext())).isInstanceOf(ApplicationConfigurationException.class).hasMessageContaining("Error: Configuration property 'delta.hide-non-delta-lake-tables' was not used");
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) ApplicationConfigurationException(io.airlift.bootstrap.ApplicationConfigurationException) Plugin(io.trino.spi.Plugin) Test(org.testng.annotations.Test)

Example 2 with Plugin

use of io.trino.spi.Plugin in project trino by trinodb.

the class TestDeltaLakePlugin method testGlueMetastore.

@Test
public void testGlueMetastore() {
    Plugin plugin = new TestingDeltaLakePlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("hive.metastore", "glue", "hive.metastore.glue.region", "us-east-2"), new TestingConnectorContext());
    assertThatThrownBy(() -> factory.create("test", ImmutableMap.of("hive.metastore", "glue", "hive.metastore.uri", "thrift://foo:1234"), new TestingConnectorContext())).isInstanceOf(ApplicationConfigurationException.class).hasMessageContaining("Error: Configuration property 'hive.metastore.uri' was not used");
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) ApplicationConfigurationException(io.airlift.bootstrap.ApplicationConfigurationException) Plugin(io.trino.spi.Plugin) Test(org.testng.annotations.Test)

Example 3 with Plugin

use of io.trino.spi.Plugin in project trino by trinodb.

the class RuleTester method defaultRuleTester.

public static RuleTester defaultRuleTester(List<Plugin> plugins, Map<String, String> sessionProperties, Optional<Integer> nodeCountForStats) {
    Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog(CATALOG_ID).setSchema("tiny").setSystemProperty("task_concurrency", // these tests don't handle exchanges from local parallel
    "1");
    for (Map.Entry<String, String> entry : sessionProperties.entrySet()) {
        sessionBuilder.setSystemProperty(entry.getKey(), entry.getValue());
    }
    Session session = sessionBuilder.build();
    LocalQueryRunner queryRunner = nodeCountForStats.map(nodeCount -> LocalQueryRunner.builder(session).withNodeCountForStats(nodeCount).build()).orElseGet(() -> LocalQueryRunner.create(session));
    queryRunner.createCatalog(session.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    plugins.forEach(queryRunner::installPlugin);
    return new RuleTester(queryRunner);
}
Also used : TypeAnalyzer.createTestingTypeAnalyzer(io.trino.sql.planner.TypeAnalyzer.createTestingTypeAnalyzer) ImmutableMap(com.google.common.collect.ImmutableMap) TransactionManager(io.trino.transaction.TransactionManager) PageSourceManager(io.trino.split.PageSourceManager) SplitManager(io.trino.split.SplitManager) FunctionManager(io.trino.metadata.FunctionManager) Plugin(io.trino.spi.Plugin) CatalogName(io.trino.connector.CatalogName) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) TypeAnalyzer(io.trino.sql.planner.TypeAnalyzer) ImmutableList(com.google.common.collect.ImmutableList) AccessControl(io.trino.security.AccessControl) TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Closeable(java.io.Closeable) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Metadata(io.trino.metadata.Metadata) Optional(java.util.Optional) Rule(io.trino.sql.planner.iterative.Rule) Session(io.trino.Session) PlannerContext(io.trino.sql.PlannerContext) TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session)

Example 4 with Plugin

use of io.trino.spi.Plugin in project trino by trinodb.

the class TestClickHousePlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    Plugin plugin = new ClickHousePlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "jdbc:clickhouse://test"), new TestingConnectorContext());
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Plugin(io.trino.spi.Plugin) Test(org.testng.annotations.Test)

Example 5 with Plugin

use of io.trino.spi.Plugin in project trino by trinodb.

the class TestDruidJdbcPlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    Plugin plugin = new DruidJdbcPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "jdbc:druid:test"), new TestingConnectorContext()).shutdown();
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Plugin(io.trino.spi.Plugin) Test(org.testng.annotations.Test)

Aggregations

Plugin (io.trino.spi.Plugin)34 ConnectorFactory (io.trino.spi.connector.ConnectorFactory)29 Test (org.testng.annotations.Test)28 TestingConnectorContext (io.trino.testing.TestingConnectorContext)22 ImmutableList (com.google.common.collect.ImmutableList)8 ImmutableMap (com.google.common.collect.ImmutableMap)8 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)8 Session (io.trino.Session)7 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)7 MockConnectorFactory (io.trino.connector.MockConnectorFactory)6 List (java.util.List)6 Optional (java.util.Optional)6 SchemaTableName (io.trino.spi.connector.SchemaTableName)5 AbstractTestQueryFramework (io.trino.testing.AbstractTestQueryFramework)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 TpchPlugin (io.trino.plugin.tpch.TpchPlugin)4 QueryRunner (io.trino.testing.QueryRunner)4 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)3 Connector (io.trino.spi.connector.Connector)3 BIGINT (io.trino.spi.type.BigintType.BIGINT)3