use of io.trino.transaction.TransactionId in project trino by trinodb.
the class TestKuduIntegrationDynamicFilter method testIncompleteDynamicFilterTimeout.
@Test(timeOut = 30_000)
public void testIncompleteDynamicFilterTimeout() throws Exception {
QueryRunner runner = getQueryRunner();
TransactionManager transactionManager = runner.getTransactionManager();
TransactionId transactionId = transactionManager.beginTransaction(false);
Session session = Session.builder(getSession()).setCatalogSessionProperty("kudu", "dynamic_filtering_wait_timeout", "1s").build().beginTransactionId(transactionId, transactionManager, new AllowAllAccessControl());
QualifiedObjectName tableName = new QualifiedObjectName("kudu", "tpch", "orders");
Optional<TableHandle> tableHandle = runner.getMetadata().getTableHandle(session, tableName);
assertTrue(tableHandle.isPresent());
SplitSource splitSource = runner.getSplitManager().getSplits(session, tableHandle.get(), UNGROUPED_SCHEDULING, new IncompleteDynamicFilter(), alwaysTrue());
List<Split> splits = new ArrayList<>();
while (!splitSource.isFinished()) {
splits.addAll(splitSource.getNextBatch(NOT_PARTITIONED, Lifespan.taskWide(), 1000).get().getSplits());
}
splitSource.close();
assertFalse(splits.isEmpty());
}
use of io.trino.transaction.TransactionId in project trino by trinodb.
the class TestIcebergMetadataListing method getStorageTable.
private SchemaTableName getStorageTable(String catalogName, String schemaName, String objectName) {
TransactionManager transactionManager = getQueryRunner().getTransactionManager();
TransactionId transactionId = transactionManager.beginTransaction(false);
Session session = getSession().beginTransactionId(transactionId, transactionManager, getQueryRunner().getAccessControl());
Optional<MaterializedViewDefinition> materializedView = getQueryRunner().getMetadata().getMaterializedView(session, new QualifiedObjectName(catalogName, schemaName, objectName));
assertThat(materializedView).isPresent();
return materializedView.get().getStorageTable().get().getSchemaTableName();
}
use of io.trino.transaction.TransactionId in project trino by trinodb.
the class TestIcebergMaterializedViews method getStorageTable.
private SchemaTableName getStorageTable(String catalogName, String schemaName, String objectName) {
TransactionManager transactionManager = getQueryRunner().getTransactionManager();
TransactionId transactionId = transactionManager.beginTransaction(false);
Session session = getSession().beginTransactionId(transactionId, transactionManager, getQueryRunner().getAccessControl());
Optional<MaterializedViewDefinition> materializedView = getQueryRunner().getMetadata().getMaterializedView(session, new QualifiedObjectName(catalogName, schemaName, objectName));
assertThat(materializedView).isPresent();
return materializedView.get().getStorageTable().get().getSchemaTableName();
}
use of io.trino.transaction.TransactionId in project trino by trinodb.
the class StartTransactionTask method execute.
@Override
public ListenableFuture<Void> execute(StartTransaction statement, QueryStateMachine stateMachine, List<Expression> parameters, WarningCollector warningCollector) {
Session session = stateMachine.getSession();
if (!session.isClientTransactionSupport()) {
throw new TrinoException(StandardErrorCode.INCOMPATIBLE_CLIENT, "Client does not support transactions");
}
if (session.getTransactionId().isPresent()) {
throw new TrinoException(StandardErrorCode.NOT_SUPPORTED, "Nested transactions not supported");
}
Optional<IsolationLevel> isolationLevel = extractIsolationLevel(statement);
Optional<Boolean> readOnly = extractReadOnly(statement);
TransactionId transactionId = transactionManager.beginTransaction(isolationLevel.orElse(TransactionManager.DEFAULT_ISOLATION), readOnly.orElse(TransactionManager.DEFAULT_READ_ONLY), false);
stateMachine.setStartedTransactionId(transactionId);
// Since the current session does not contain this new transaction ID, we need to manually mark it as inactive
// when this statement completes.
transactionManager.trySetInactive(transactionId);
return immediateVoidFuture();
}
use of io.trino.transaction.TransactionId in project trino by trinodb.
the class AbstractPropertiesSystemTable method cursor.
@Override
public final RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
InMemoryRecordSet.Builder table = InMemoryRecordSet.builder(tableMetadata);
List<CatalogName> catalogNames = transactionManager.getCatalogs(transactionId).keySet().stream().sorted().map(CatalogName::new).collect(toImmutableList());
for (CatalogName catalogName : catalogNames) {
catalogProperties.apply(catalogName).stream().sorted(Comparator.comparing(PropertyMetadata::getName)).forEach(propertyMetadata -> table.addRow(catalogName.toString(), propertyMetadata.getName(), firstNonNull(propertyMetadata.getDefaultValue(), "").toString(), propertyMetadata.getSqlType().toString(), propertyMetadata.getDescription()));
}
return table.build().cursor();
}
Aggregations