Search in sources :

Example 66 with TableHandle

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

the class TestRuntimeReorderJoinSides method setUp.

@BeforeClass
public void setUp() {
    tester = new RuleTester(ImmutableList.of(), ImmutableMap.of(), Optional.of(NODES_COUNT));
    connectorId = tester.getCurrentConnectorId();
    TpchTableHandle nationTpchTableHandle = new TpchTableHandle("nation", 1.0);
    TpchTableHandle supplierTpchTableHandle = new TpchTableHandle("supplier", 1.0);
    nationTableHandle = new TableHandle(connectorId, nationTpchTableHandle, TestingTransactionHandle.create(), Optional.of(new TpchTableLayoutHandle(nationTpchTableHandle, TupleDomain.all())));
    supplierTableHandle = new TableHandle(connectorId, supplierTpchTableHandle, TestingTransactionHandle.create(), Optional.of(new TpchTableLayoutHandle(supplierTpchTableHandle, TupleDomain.all())));
    nationColumnHandle = new TpchColumnHandle("nationkey", BIGINT);
    suppColumnHandle = new TpchColumnHandle("suppkey", BIGINT);
}
Also used : TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) RuleTester(com.facebook.presto.sql.planner.iterative.rule.test.RuleTester) TableHandle(com.facebook.presto.spi.TableHandle) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) TpchTableLayoutHandle(com.facebook.presto.tpch.TpchTableLayoutHandle) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Example 67 with TableHandle

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

the class TestValidateStreamingJoins method setup.

@BeforeClass
public void setup() {
    Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog("local").setSchema("tiny");
    testSession = sessionBuilder.build();
    metadata = getQueryRunner().getMetadata();
    sqlParser = getQueryRunner().getSqlParser();
    TpchTableHandle nationTpchTableHandle = new TpchTableHandle("nation", 1.0);
    TpchTableHandle supplierTpchTableHandle = new TpchTableHandle("supplier", 1.0);
    ConnectorId connectorId = getCurrentConnectorId();
    nationTableHandle = new TableHandle(connectorId, nationTpchTableHandle, TestingTransactionHandle.create(), Optional.of(new TpchTableLayoutHandle(nationTpchTableHandle, TupleDomain.all())));
    supplierTableHandle = new TableHandle(connectorId, supplierTpchTableHandle, TestingTransactionHandle.create(), Optional.of(new TpchTableLayoutHandle(supplierTpchTableHandle, TupleDomain.all())));
    nationColumnHandle = new TpchColumnHandle("nationkey", BIGINT);
    suppColumnHandle = new TpchColumnHandle("suppkey", BIGINT);
}
Also used : TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) TableHandle(com.facebook.presto.spi.TableHandle) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) TpchTableLayoutHandle(com.facebook.presto.tpch.TpchTableLayoutHandle) Session(com.facebook.presto.Session) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) ConnectorId(com.facebook.presto.spi.ConnectorId) BeforeClass(org.testng.annotations.BeforeClass)

Example 68 with TableHandle

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

the class TestPrestoSparkLauncherIntegrationSmokeTest method dropTable.

private void dropTable(String table) {
    // LocalQueryRunner doesn't support DROP TABLE
    localQueryRunner.inTransaction(localQueryRunner.getDefaultSession(), transactionSession -> {
        Metadata metadata = localQueryRunner.getMetadata();
        TableHandle tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName("hive", "default", table)).get();
        metadata.dropTable(transactionSession, tableHandle);
        return null;
    });
}
Also used : Metadata(com.facebook.presto.metadata.Metadata) TableHandle(com.facebook.presto.spi.TableHandle) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName)

Example 69 with TableHandle

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

the class TestMetadataManager method testGetTableStatisticsDoesNotThrow.

@Test
public void testGetTableStatisticsDoesNotThrow() {
    Session session = testSessionBuilder().setSystemProperty("ignore_stats_calculator_failures", "true").build();
    TableHandle tableHandle = new TableHandle(new ConnectorId("upper_case_schema_catalog"), new ConnectorTableHandle() {
    }, TestingTransactionHandle.create(), Optional.empty());
    TransactionBuilder.transaction(queryRunner.getTransactionManager(), queryRunner.getAccessControl()).execute(session, transactionSession -> {
        queryRunner.getMetadata().getCatalogHandle(transactionSession, "upper_case_schema_catalog");
        assertEquals(queryRunner.getMetadata().getTableStatistics(transactionSession, tableHandle, ImmutableList.of(), alwaysTrue()), TableStatistics.empty());
    });
}
Also used : ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) TableHandle(com.facebook.presto.spi.TableHandle) Session(com.facebook.presto.Session) ConnectorId(com.facebook.presto.spi.ConnectorId) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 70 with TableHandle

use of com.facebook.presto.spi.TableHandle 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

TableHandle (com.facebook.presto.spi.TableHandle)70 ConnectorId (com.facebook.presto.spi.ConnectorId)37 ColumnHandle (com.facebook.presto.spi.ColumnHandle)29 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)22 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)21 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)21 ImmutableList (com.google.common.collect.ImmutableList)20 ImmutableMap (com.google.common.collect.ImmutableMap)19 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)18 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)16 Session (com.facebook.presto.Session)15 Type (com.facebook.presto.common.type.Type)15 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)15 Optional (java.util.Optional)15 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)14 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)14 List (java.util.List)14 Metadata (com.facebook.presto.metadata.Metadata)13 ConnectorInsertTableHandle (com.facebook.presto.spi.ConnectorInsertTableHandle)13 ConnectorSession (com.facebook.presto.spi.ConnectorSession)13