Search in sources :

Example 16 with ConnectorFactory

use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.

the class ConnectorManager method addConnectorFactory.

public synchronized void addConnectorFactory(ConnectorFactory connectorFactory) {
    checkState(!stopped.get(), "ConnectorManager is stopped");
    ConnectorFactory existingConnectorFactory = connectorFactories.putIfAbsent(connectorFactory.getName(), connectorFactory);
    checkArgument(existingConnectorFactory == null, "Connector %s is already registered", connectorFactory.getName());
    handleResolver.addConnectorName(connectorFactory.getName(), connectorFactory.getHandleResolver());
}
Also used : ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory)

Example 17 with ConnectorFactory

use of com.facebook.presto.spi.connector.ConnectorFactory 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 18 with ConnectorFactory

use of com.facebook.presto.spi.connector.ConnectorFactory 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)

Example 19 with ConnectorFactory

use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.

the class TestRaptorPlugin method testPlugin.

@Test
public void testPlugin() throws Exception {
    RaptorPlugin plugin = loadPlugin(RaptorPlugin.class);
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    assertInstanceOf(factory, RaptorConnectorFactory.class);
    File tmpDir = Files.createTempDir();
    try {
        Map<String, String> config = ImmutableMap.<String, String>builder().put("metadata.db.type", "h2").put("metadata.db.filename", tmpDir.getAbsolutePath()).put("storage.data-directory", tmpDir.toURI().toString()).build();
        factory.create("test", config, new TestingConnectorContext());
    } finally {
        deleteRecursively(tmpDir.toPath(), ALLOW_INSECURE);
    }
}
Also used : ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext) File(java.io.File) Test(org.testng.annotations.Test)

Example 20 with ConnectorFactory

use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.

the class RaptorBenchmarkQueryRunner method createLocalQueryRunner.

public static LocalQueryRunner createLocalQueryRunner() {
    Session session = testSessionBuilder().setCatalog("raptor").setSchema("benchmark").build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);
    // add tpch
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    // add raptor
    ConnectorFactory raptorConnectorFactory = getOnlyElement(new RaptorPlugin().getConnectorFactories());
    Map<String, String> config = createRaptorConfig(TPCH_CACHE_DIR);
    localQueryRunner.createCatalog("raptor", raptorConnectorFactory, config);
    if (!localQueryRunner.tableExists(session, "orders")) {
        localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
    }
    if (!localQueryRunner.tableExists(session, "lineitem")) {
        localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
    }
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session)

Aggregations

ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)20 Test (org.testng.annotations.Test)14 TestingConnectorContext (com.facebook.presto.testing.TestingConnectorContext)12 Plugin (com.facebook.presto.spi.Plugin)8 Connector (com.facebook.presto.spi.connector.Connector)6 Session (com.facebook.presto.Session)3 Type (com.facebook.presto.common.type.Type)2 MetadataManager (com.facebook.presto.metadata.MetadataManager)2 ConnectorId (com.facebook.presto.spi.ConnectorId)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Logger (com.facebook.airlift.log.Logger)1 NodeInfo (com.facebook.airlift.node.NodeInfo)1 TEST_SESSION (com.facebook.presto.SessionTestUtils.TEST_SESSION)1 IGNORE_STATS_CALCULATOR_FAILURES (com.facebook.presto.SystemSessionProperties.IGNORE_STATS_CALCULATOR_FAILURES)1 BlockEncoding (com.facebook.presto.common.block.BlockEncoding)1 BlockEncodingSerde (com.facebook.presto.common.block.BlockEncodingSerde)1 ParametricType (com.facebook.presto.common.type.ParametricType)1 TypeManager (com.facebook.presto.common.type.TypeManager)1 MockConnectorFactory (com.facebook.presto.connector.MockConnectorFactory)1 InformationSchemaConnector (com.facebook.presto.connector.informationSchema.InformationSchemaConnector)1