Search in sources :

Example 21 with TpchConnectorFactory

use of com.facebook.presto.tpch.TpchConnectorFactory in project presto by prestodb.

the class StatsCalculatorTester method createQueryRunner.

private static LocalQueryRunner createQueryRunner(Session session) {
    LocalQueryRunner queryRunner = new LocalQueryRunner(session);
    queryRunner.createCatalog(session.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    return queryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner)

Example 22 with TpchConnectorFactory

use of com.facebook.presto.tpch.TpchConnectorFactory in project presto by prestodb.

the class TestTransactionManager method testFailedTransactionWorkflow.

@Test
public void testFailedTransactionWorkflow() {
    try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
        CatalogManager catalogManager = new CatalogManager();
        TransactionManager transactionManager = InMemoryTransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), catalogManager, finishingExecutor);
        Connector c1 = new TpchConnectorFactory().create(CATALOG_NAME, ImmutableMap.of(), new TestingConnectorContext());
        registerConnector(catalogManager, transactionManager, CATALOG_NAME, CONNECTOR_ID, c1);
        TransactionId transactionId = transactionManager.beginTransaction(false);
        assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertFalse(transactionInfo.isAutoCommitContext());
        assertTrue(transactionInfo.getConnectorIds().isEmpty());
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        ConnectorMetadata metadata = transactionManager.getOptionalCatalogMetadata(transactionId, CATALOG_NAME).get().getMetadata();
        metadata.listSchemaNames(TEST_SESSION.toConnectorSession(CONNECTOR_ID));
        transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertEquals(transactionInfo.getConnectorIds(), ImmutableList.of(CONNECTOR_ID, INFORMATION_SCHEMA_ID, SYSTEM_TABLES_ID));
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        transactionManager.fail(transactionId);
        assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        try {
            transactionManager.getCatalogMetadata(transactionId, CONNECTOR_ID);
            fail();
        } catch (PrestoException e) {
            assertEquals(e.getErrorCode(), TRANSACTION_ALREADY_ABORTED.toErrorCode());
        }
        assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        getFutureValue(transactionManager.asyncAbort(transactionId));
        assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    }
}
Also used : InformationSchemaConnector(com.facebook.presto.connector.informationSchema.InformationSchemaConnector) Connector(com.facebook.presto.spi.connector.Connector) SystemConnector(com.facebook.presto.connector.system.SystemConnector) TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext) PrestoException(com.facebook.presto.spi.PrestoException) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) CatalogManager(com.facebook.presto.metadata.CatalogManager) Test(org.testng.annotations.Test)

Example 23 with TpchConnectorFactory

use of com.facebook.presto.tpch.TpchConnectorFactory in project presto by prestodb.

the class TestTransactionManager method testAbortedTransactionWorkflow.

@Test
public void testAbortedTransactionWorkflow() {
    try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
        CatalogManager catalogManager = new CatalogManager();
        TransactionManager transactionManager = InMemoryTransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), catalogManager, finishingExecutor);
        Connector c1 = new TpchConnectorFactory().create(CATALOG_NAME, ImmutableMap.of(), new TestingConnectorContext());
        registerConnector(catalogManager, transactionManager, CATALOG_NAME, CONNECTOR_ID, c1);
        TransactionId transactionId = transactionManager.beginTransaction(false);
        assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertFalse(transactionInfo.isAutoCommitContext());
        assertTrue(transactionInfo.getConnectorIds().isEmpty());
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        ConnectorMetadata metadata = transactionManager.getOptionalCatalogMetadata(transactionId, CATALOG_NAME).get().getMetadata();
        metadata.listSchemaNames(TEST_SESSION.toConnectorSession(CONNECTOR_ID));
        transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertEquals(transactionInfo.getConnectorIds(), ImmutableList.of(CONNECTOR_ID, INFORMATION_SCHEMA_ID, SYSTEM_TABLES_ID));
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        getFutureValue(transactionManager.asyncAbort(transactionId));
        assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    }
}
Also used : InformationSchemaConnector(com.facebook.presto.connector.informationSchema.InformationSchemaConnector) Connector(com.facebook.presto.spi.connector.Connector) SystemConnector(com.facebook.presto.connector.system.SystemConnector) TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) CatalogManager(com.facebook.presto.metadata.CatalogManager) Test(org.testng.annotations.Test)

Example 24 with TpchConnectorFactory

use of com.facebook.presto.tpch.TpchConnectorFactory in project presto by prestodb.

the class TestPlannerWarnings method setUp.

@BeforeClass
public void setUp() {
    queryRunner = new LocalQueryRunner(testSessionBuilder().setCatalog("local").setSchema("tiny").build());
    queryRunner.createCatalog(queryRunner.getDefaultSession().getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) BeforeClass(org.testng.annotations.BeforeClass)

Example 25 with TpchConnectorFactory

use of com.facebook.presto.tpch.TpchConnectorFactory in project presto by prestodb.

the class TestLocalExecutionPlanner method setUp.

@BeforeClass
public void setUp() {
    runner = new LocalQueryRunner(TEST_SESSION);
    runner.createCatalog(runner.getDefaultSession().getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)30 LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)25 Session (com.facebook.presto.Session)18 BeforeClass (org.testng.annotations.BeforeClass)6 InformationSchemaConnector (com.facebook.presto.connector.informationSchema.InformationSchemaConnector)4 SystemConnector (com.facebook.presto.connector.system.SystemConnector)4 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)4 Connector (com.facebook.presto.spi.connector.Connector)4 TestingConnectorContext (com.facebook.presto.testing.TestingConnectorContext)4 Test (org.testng.annotations.Test)4 CatalogManager (com.facebook.presto.metadata.CatalogManager)3 MemoryConnectorFactory (com.facebook.presto.plugin.memory.MemoryConnectorFactory)3 ConnectorId (com.facebook.presto.spi.ConnectorId)3 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)3 TestingSession.testSessionBuilder (com.facebook.presto.testing.TestingSession.testSessionBuilder)3 SessionBuilder (com.facebook.presto.Session.SessionBuilder)2 ConnectorId (com.facebook.presto.connector.ConnectorId)2 QueryId (com.facebook.presto.spi.QueryId)2 ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)2 MemoryPoolId (com.facebook.presto.spi.memory.MemoryPoolId)2