Search in sources :

Example 11 with TransactionId

use of io.prestosql.transaction.TransactionId in project hetu-core by openlookeng.

the class TestInformationSchemaMetadata method testInformationSchemaPredicatePushdown.

/**
 * Tests information schema predicate pushdown when both schema and table name are specified.
 */
@Test
public void testInformationSchemaPredicatePushdown() {
    TransactionId transactionId = transactionManager.beginTransaction(false);
    ImmutableMap.Builder<ColumnHandle, Domain> domains = new ImmutableMap.Builder<>();
    domains.put(new InformationSchemaColumnHandle("table_schema"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_schema")));
    domains.put(new InformationSchemaColumnHandle("table_name"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_view")));
    Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build()));
    ConnectorSession session = createNewSession(transactionId);
    ConnectorMetadata connectorMetadata = new InformationSchemaMetadata("test_catalog", this.metadata);
    InformationSchemaTableHandle tableHandle = (InformationSchemaTableHandle) connectorMetadata.getTableHandle(session, new SchemaTableName("information_schema", "views"));
    tableHandle = connectorMetadata.applyFilter(session, tableHandle, constraint).map(ConstraintApplicationResult::getHandle).map(InformationSchemaTableHandle.class::cast).orElseThrow(AssertionError::new);
    assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema", "test_view")));
}
Also used : InformationSchemaColumnHandle(io.prestosql.connector.informationschema.InformationSchemaColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Constraint(io.prestosql.spi.connector.Constraint) TestingSession.testSessionBuilder(io.prestosql.testing.TestingSession.testSessionBuilder) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ImmutableMap(com.google.common.collect.ImmutableMap) TransactionId(io.prestosql.transaction.TransactionId) InformationSchemaTableHandle(io.prestosql.connector.informationschema.InformationSchemaTableHandle) InformationSchemaColumnHandle(io.prestosql.connector.informationschema.InformationSchemaColumnHandle) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) InformationSchemaMetadata(io.prestosql.connector.informationschema.InformationSchemaMetadata) TupleDomain(io.prestosql.spi.predicate.TupleDomain) Domain(io.prestosql.spi.predicate.Domain) Test(org.testng.annotations.Test)

Example 12 with TransactionId

use of io.prestosql.transaction.TransactionId in project hetu-core by openlookeng.

the class SystemConnectorSessionUtil method toSession.

// this does not preserve any connector properties (for the system connector)
public static Session toSession(ConnectorTransactionHandle transactionHandle, ConnectorSession session) {
    TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
    ConnectorIdentity connectorIdentity = session.getIdentity();
    Identity identity = new Identity(connectorIdentity.getUser(), connectorIdentity.getPrincipal());
    return Session.builder(new SessionPropertyManager(SYSTEM_SESSION_PROPERTIES)).setQueryId(new QueryId(session.getQueryId())).setTransactionId(transactionId).setCatalog("catalog").setSchema("schema").setPath(new SqlPath(Optional.of("path"))).setIdentity(identity).setTimeZoneKey(session.getTimeZoneKey()).setLocale(session.getLocale()).setStartTime(session.getStartTime()).build();
}
Also used : SqlPath(io.prestosql.sql.SqlPath) QueryId(io.prestosql.spi.QueryId) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) ConnectorIdentity(io.prestosql.spi.security.ConnectorIdentity) ConnectorIdentity(io.prestosql.spi.security.ConnectorIdentity) Identity(io.prestosql.spi.security.Identity) TransactionId(io.prestosql.transaction.TransactionId)

Aggregations

TransactionId (io.prestosql.transaction.TransactionId)12 Session (io.prestosql.Session)5 PrestoException (io.prestosql.spi.PrestoException)3 ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)3 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 InformationSchemaColumnHandle (io.prestosql.connector.informationschema.InformationSchemaColumnHandle)2 InformationSchemaMetadata (io.prestosql.connector.informationschema.InformationSchemaMetadata)2 InformationSchemaTableHandle (io.prestosql.connector.informationschema.InformationSchemaTableHandle)2 Catalog (io.prestosql.metadata.Catalog)2 CatalogManager (io.prestosql.metadata.CatalogManager)2 SessionPropertyManager (io.prestosql.metadata.SessionPropertyManager)2 AccessControlManager (io.prestosql.security.AccessControlManager)2 CatalogName (io.prestosql.spi.connector.CatalogName)2 ColumnMetadata (io.prestosql.spi.connector.ColumnMetadata)2 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)2 ConnectorTableMetadata (io.prestosql.spi.connector.ConnectorTableMetadata)2 Constraint (io.prestosql.spi.connector.Constraint)2 PropertyMetadata (io.prestosql.spi.session.PropertyMetadata)2 IsolationLevel (io.prestosql.spi.transaction.IsolationLevel)2