Search in sources :

Example 11 with Plugin

use of com.facebook.presto.spi.Plugin in project presto by prestodb.

the class TestingPrestoServerLauncher method run.

public void run() throws Exception {
    try (TestingPrestoServer server = new TestingPrestoServer()) {
        for (String pluginClass : options.getPluginClassNames()) {
            Plugin plugin = (Plugin) Class.forName(pluginClass).getConstructor().newInstance();
            server.installPlugin(plugin);
        }
        for (Catalog catalog : options.getCatalogs()) {
            server.createCatalog(catalog.getCatalogName(), catalog.getConnectorName());
        }
        System.out.println(server.getAddress());
        waitForInterruption();
    }
}
Also used : Catalog(com.facebook.presto.server.testing.TestingPrestoServerLauncherOptions.Catalog) Plugin(com.facebook.presto.spi.Plugin)

Example 12 with Plugin

use of com.facebook.presto.spi.Plugin in project presto by prestodb.

the class TestPostgreSqlPlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    Plugin plugin = new PostgreSqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
Also used : ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext) Plugin(com.facebook.presto.spi.Plugin) Test(org.testng.annotations.Test)

Example 13 with Plugin

use of com.facebook.presto.spi.Plugin in project presto by prestodb.

the class TestMetadataManager method setUp.

@BeforeClass
public void setUp() throws Exception {
    queryRunner = TpchQueryRunnerBuilder.builder().build();
    queryRunner.installPlugin(new Plugin() {

        @Override
        public Iterable<ConnectorFactory> getConnectorFactories() {
            MockConnectorFactory connectorFactory = MockConnectorFactory.builder().withListSchemaNames(session -> ImmutableList.of("UPPER_CASE_SCHEMA")).withListTables((session, schemaNameOrNull) -> {
                throw new UnsupportedOperationException();
            }).withGetViews((session, prefix) -> ImmutableMap.of()).withGetColumnHandles((session, tableHandle) -> {
                throw new UnsupportedOperationException();
            }).withGetTableStatistics(() -> {
                throw new UnsupportedOperationException();
            }).build();
            return ImmutableList.of(connectorFactory);
        }
    });
    queryRunner.createCatalog("upper_case_schema_catalog", "mock");
    metadataManager = (MetadataManager) queryRunner.getMetadata();
}
Also used : MockConnectorFactory(com.facebook.presto.connector.MockConnectorFactory) MetadataManager(com.facebook.presto.metadata.MetadataManager) TableStatistics(com.facebook.presto.spi.statistics.TableStatistics) Assert.assertEquals(org.testng.Assert.assertEquals) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test) TEST_SESSION(com.facebook.presto.SessionTestUtils.TEST_SESSION) ImmutableList(com.google.common.collect.ImmutableList) IGNORE_STATS_CALCULATOR_FAILURES(com.facebook.presto.SystemSessionProperties.IGNORE_STATS_CALCULATOR_FAILURES) FAILED(com.facebook.presto.execution.QueryState.FAILED) TableHandle(com.facebook.presto.spi.TableHandle) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo) TpchQueryRunnerBuilder(com.facebook.presto.tests.tpch.TpchQueryRunnerBuilder) TransactionBuilder(com.facebook.presto.transaction.TransactionBuilder) AfterClass(org.testng.annotations.AfterClass) RUNNING(com.facebook.presto.execution.QueryState.RUNNING) ImmutableMap(com.google.common.collect.ImmutableMap) Language(org.intellij.lang.annotations.Language) Session(com.facebook.presto.Session) TestingSessionContext(com.facebook.presto.execution.TestingSessionContext) BeforeClass(org.testng.annotations.BeforeClass) Assert.fail(org.testng.Assert.fail) Constraint.alwaysTrue(com.facebook.presto.spi.Constraint.alwaysTrue) DispatchManager(com.facebook.presto.dispatcher.DispatchManager) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) TestingSession.testSessionBuilder(com.facebook.presto.testing.TestingSession.testSessionBuilder) ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) Plugin(com.facebook.presto.spi.Plugin) List(java.util.List) QueryId(com.facebook.presto.spi.QueryId) Optional(java.util.Optional) ConnectorId(com.facebook.presto.spi.ConnectorId) MockConnectorFactory(com.facebook.presto.connector.MockConnectorFactory) Plugin(com.facebook.presto.spi.Plugin) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

Plugin (com.facebook.presto.spi.Plugin)13 ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)8 Test (org.testng.annotations.Test)8 TestingConnectorContext (com.facebook.presto.testing.TestingConnectorContext)7 ImmutableMap (com.google.common.collect.ImmutableMap)4 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)3 Session (com.facebook.presto.Session)1 TEST_SESSION (com.facebook.presto.SessionTestUtils.TEST_SESSION)1 IGNORE_STATS_CALCULATOR_FAILURES (com.facebook.presto.SystemSessionProperties.IGNORE_STATS_CALCULATOR_FAILURES)1 MockConnectorFactory (com.facebook.presto.connector.MockConnectorFactory)1 DispatchManager (com.facebook.presto.dispatcher.DispatchManager)1 FAILED (com.facebook.presto.execution.QueryState.FAILED)1 RUNNING (com.facebook.presto.execution.QueryState.RUNNING)1 TestingSessionContext (com.facebook.presto.execution.TestingSessionContext)1 MetadataManager (com.facebook.presto.metadata.MetadataManager)1 H2ResourceGroupsDao (com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao)1 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)1 Catalog (com.facebook.presto.server.testing.TestingPrestoServerLauncherOptions.Catalog)1 ConnectorId (com.facebook.presto.spi.ConnectorId)1