Search in sources :

Example 96 with Session

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

the class TestCommitTask method testNoTransactionCommit.

@Test
public void testNoTransactionCommit() {
    TransactionManager transactionManager = createTestTransactionManager();
    Session session = sessionBuilder().build();
    QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, transactionManager);
    assertPrestoExceptionThrownBy(() -> getFutureValue(new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(NOT_IN_TRANSACTION);
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
Also used : Commit(io.prestosql.sql.tree.Commit) TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 97 with Session

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

the class TestCommitTask method testUnknownTransactionCommit.

@Test
public void testUnknownTransactionCommit() {
    TransactionManager transactionManager = createTestTransactionManager();
    Session session = sessionBuilder().setTransactionId(// Use a random transaction ID that is unknown to the system
    TransactionId.create()).build();
    QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, transactionManager);
    Future<?> future = new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager()));
    assertPrestoExceptionThrownBy(() -> getFutureValue(future)).hasErrorCode(UNKNOWN_TRANSACTION);
    // Still issue clear signal
    assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
Also used : Commit(io.prestosql.sql.tree.Commit) TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 98 with Session

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

the class TestDropCacheTask method testDropWithNonQualifiedName.

@Test
public void testDropWithNonQualifiedName() {
    QualifiedName tableName = QualifiedName.of(table3);
    QualifiedName fullName = QualifiedName.of(CATALOG_NAME, schema, table3);
    DropCache statement = new DropCache(tableName, true);
    Session session = testSessionBuilder().setTransactionId(transactionManager.beginTransaction(false)).setCatalog(CATALOG_NAME).setSchema(schema).build();
    QueryStateMachine queryStateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    getFutureValue(new DropCacheTask().execute(statement, createTestTransactionManager(), metadata, new AllowAllAccessControl(), queryStateMachine, Collections.emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    assertFalse(SplitCacheMap.getInstance().cacheExists(fullName));
}
Also used : DropCache(io.prestosql.sql.tree.DropCache) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) QualifiedName(io.prestosql.sql.tree.QualifiedName) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 99 with Session

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

the class TestRollbackTask method testNoTransactionRollback.

@Test
public void testNoTransactionRollback() {
    TransactionManager transactionManager = createTestTransactionManager();
    Session session = sessionBuilder().build();
    QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, transactionManager);
    assertPrestoExceptionThrownBy(() -> getFutureValue((Future<?>) new RollbackTask().execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(NOT_IN_TRANSACTION);
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
Also used : TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) Rollback(io.prestosql.sql.tree.Rollback) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 100 with Session

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

the class TestQueryPreparer method testTooManyParameters.

@Test
public void testTooManyParameters() {
    Session session = testSessionBuilder().addPreparedStatement("my_query", "SELECT * FROM foo where col1 = ?").build();
    assertSemanticExceptionThrownBy(() -> QUERY_PREPARER.prepareQuery(session, "EXECUTE my_query USING 1,2")).hasErrorCode(INVALID_PARAMETER_USAGE);
}
Also used : Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Aggregations

Session (io.prestosql.Session)281 Test (org.testng.annotations.Test)147 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)54 List (java.util.List)53 Optional (java.util.Optional)51 MaterializedResult (io.prestosql.testing.MaterializedResult)47 Metadata (io.prestosql.metadata.Metadata)44 QualifiedObjectName (io.prestosql.spi.connector.QualifiedObjectName)44 Map (java.util.Map)44 Objects.requireNonNull (java.util.Objects.requireNonNull)40 TableHandle (io.prestosql.spi.metadata.TableHandle)34 PrestoException (io.prestosql.spi.PrestoException)32 ImmutableList (com.google.common.collect.ImmutableList)31 Type (io.prestosql.spi.type.Type)31 Set (java.util.Set)31 ImmutableMap (com.google.common.collect.ImmutableMap)30 HashMap (java.util.HashMap)30 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)28 AbstractTestIntegrationSmokeTest (io.prestosql.tests.AbstractTestIntegrationSmokeTest)28 ImmutableSet (com.google.common.collect.ImmutableSet)27