diff --git a/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java b/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java index b2cde3aeea4e..8974ecde4e11 100644 --- a/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java @@ -28,7 +28,8 @@ import io.trino.sql.tree.AddColumn; import io.trino.sql.tree.ColumnDefinition; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Map; @@ -49,10 +50,21 @@ import static io.trino.sql.analyzer.TypeSignatureTranslator.toTypeSignature; import static io.trino.type.UnknownType.UNKNOWN; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class AddColumnTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public AddColumnTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -62,9 +74,6 @@ public String getName() @Override public ListenableFuture execute( AddColumn statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/CallTask.java b/core/trino-main/src/main/java/io/trino/execution/CallTask.java index 9c5c3d5eeb8f..e41902e6d179 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CallTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CallTask.java @@ -39,6 +39,8 @@ import io.trino.sql.tree.Parameter; import io.trino.transaction.TransactionManager; +import javax.inject.Inject; + import java.lang.invoke.MethodType; import java.util.ArrayList; import java.util.HashMap; @@ -63,10 +65,23 @@ import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static io.trino.sql.planner.ExpressionInterpreter.evaluateConstantExpression; import static java.util.Arrays.asList; +import static java.util.Objects.requireNonNull; public class CallTask implements DataDefinitionTask { + private final TransactionManager transactionManager; + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public CallTask(TransactionManager transactionManager, Metadata metadata, AccessControl accessControl) + { + this.transactionManager = requireNonNull(transactionManager, "transactionManager is null"); + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -76,9 +91,6 @@ public String getName() @Override public ListenableFuture execute( Call call, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/CommentTask.java b/core/trino-main/src/main/java/io/trino/execution/CommentTask.java index b5f91a46ea9e..1e482f350b91 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CommentTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CommentTask.java @@ -24,7 +24,8 @@ import io.trino.sql.tree.Comment; import io.trino.sql.tree.Expression; import io.trino.sql.tree.QualifiedName; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Map; @@ -37,10 +38,21 @@ import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class CommentTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public CommentTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -50,9 +62,6 @@ public String getName() @Override public ListenableFuture execute( Comment statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/CommitTask.java b/core/trino-main/src/main/java/io/trino/execution/CommitTask.java index 50419d9070a8..f777048525c4 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CommitTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CommitTask.java @@ -16,21 +16,30 @@ import com.google.common.util.concurrent.ListenableFuture; import io.trino.Session; import io.trino.execution.warnings.WarningCollector; -import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.spi.TrinoException; import io.trino.sql.tree.Commit; import io.trino.sql.tree.Expression; import io.trino.transaction.TransactionId; import io.trino.transaction.TransactionManager; +import javax.inject.Inject; + import java.util.List; import static io.trino.spi.StandardErrorCode.NOT_IN_TRANSACTION; +import static java.util.Objects.requireNonNull; public class CommitTask implements DataDefinitionTask { + private final TransactionManager transactionManager; + + @Inject + public CommitTask(TransactionManager transactionManager) + { + this.transactionManager = requireNonNull(transactionManager, "transactionManager is null"); + } + @Override public String getName() { @@ -40,9 +49,6 @@ public String getName() @Override public ListenableFuture execute( Commit statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/CreateMaterializedViewTask.java b/core/trino-main/src/main/java/io/trino/execution/CreateMaterializedViewTask.java index 8ce756bb81c6..8b9933aa12a1 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CreateMaterializedViewTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CreateMaterializedViewTask.java @@ -31,7 +31,6 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.NodeRef; import io.trino.sql.tree.Parameter; -import io.trino.transaction.TransactionManager; import javax.inject.Inject; @@ -51,13 +50,17 @@ public class CreateMaterializedViewTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; private final SqlParser sqlParser; private final GroupProvider groupProvider; private final StatsCalculator statsCalculator; @Inject - public CreateMaterializedViewTask(SqlParser sqlParser, GroupProvider groupProvider, StatsCalculator statsCalculator) + public CreateMaterializedViewTask(Metadata metadata, AccessControl accessControl, SqlParser sqlParser, GroupProvider groupProvider, StatsCalculator statsCalculator) { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); this.sqlParser = requireNonNull(sqlParser, "sqlParser is null"); this.groupProvider = requireNonNull(groupProvider, "groupProvider is null"); this.statsCalculator = requireNonNull(statsCalculator, "statsCalculator is null"); @@ -72,9 +75,6 @@ public String getName() @Override public ListenableFuture execute( CreateMaterializedView statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/CreateRoleTask.java b/core/trino-main/src/main/java/io/trino/execution/CreateRoleTask.java index 7bce99e6759f..f460b6356dfc 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CreateRoleTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CreateRoleTask.java @@ -22,7 +22,8 @@ import io.trino.sql.tree.CreateRole; import io.trino.sql.tree.Expression; import io.trino.sql.tree.Identifier; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -34,10 +35,21 @@ import static io.trino.spi.StandardErrorCode.ROLE_ALREADY_EXISTS; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class CreateRoleTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public CreateRoleTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -47,9 +59,6 @@ public String getName() @Override public ListenableFuture execute( CreateRole statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/CreateSchemaTask.java b/core/trino-main/src/main/java/io/trino/execution/CreateSchemaTask.java index 4054b49bcd9f..e8dee93d9970 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CreateSchemaTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CreateSchemaTask.java @@ -26,7 +26,8 @@ import io.trino.spi.security.TrinoPrincipal; import io.trino.sql.tree.CreateSchema; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Map; @@ -42,10 +43,21 @@ import static io.trino.sql.NodeUtils.mapFromProperties; import static io.trino.sql.ParameterUtils.parameterExtractor; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class CreateSchemaTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public CreateSchemaTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -55,9 +67,6 @@ public String getName() @Override public ListenableFuture execute( CreateSchema statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/CreateTableTask.java b/core/trino-main/src/main/java/io/trino/execution/CreateTableTask.java index 44df003646b9..3e87f7965cb9 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CreateTableTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CreateTableTask.java @@ -43,7 +43,6 @@ import io.trino.sql.tree.NodeRef; import io.trino.sql.tree.Parameter; import io.trino.sql.tree.TableElement; -import io.trino.transaction.TransactionManager; import javax.inject.Inject; @@ -80,15 +79,20 @@ import static io.trino.sql.tree.LikeClause.PropertiesOption.INCLUDING; import static io.trino.type.UnknownType.UNKNOWN; import static java.lang.String.format; +import static java.util.Objects.requireNonNull; public class CreateTableTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; private final boolean disableSetPropertiesSecurityCheckForCreateDdl; @Inject - public CreateTableTask(FeaturesConfig featuresConfig) + public CreateTableTask(Metadata metadata, AccessControl accessControl, FeaturesConfig featuresConfig) { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); this.disableSetPropertiesSecurityCheckForCreateDdl = featuresConfig.isDisableSetPropertiesSecurityCheckForCreateDdl(); } @@ -101,18 +105,15 @@ public String getName() @Override public ListenableFuture execute( CreateTable statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) { - return internalExecute(statement, metadata, accessControl, stateMachine.getSession(), parameters, output -> stateMachine.setOutput(Optional.of(output))); + return internalExecute(statement, stateMachine.getSession(), parameters, output -> stateMachine.setOutput(Optional.of(output))); } @VisibleForTesting - ListenableFuture internalExecute(CreateTable statement, Metadata metadata, AccessControl accessControl, Session session, List parameters, Consumer outputConsumer) + ListenableFuture internalExecute(CreateTable statement, Session session, List parameters, Consumer outputConsumer) { checkArgument(!statement.getElements().isEmpty(), "no columns for table"); diff --git a/core/trino-main/src/main/java/io/trino/execution/CreateViewTask.java b/core/trino-main/src/main/java/io/trino/execution/CreateViewTask.java index 9744ec01258e..c8c050c830e0 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CreateViewTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CreateViewTask.java @@ -29,7 +29,6 @@ import io.trino.sql.parser.SqlParser; import io.trino.sql.tree.CreateView; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; import javax.inject.Inject; @@ -47,13 +46,17 @@ public class CreateViewTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; private final SqlParser sqlParser; private final GroupProvider groupProvider; private final StatsCalculator statsCalculator; @Inject - public CreateViewTask(SqlParser sqlParser, GroupProvider groupProvider, StatsCalculator statsCalculator) + public CreateViewTask(Metadata metadata, AccessControl accessControl, SqlParser sqlParser, GroupProvider groupProvider, StatsCalculator statsCalculator) { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); this.sqlParser = requireNonNull(sqlParser, "sqlParser is null"); this.groupProvider = requireNonNull(groupProvider, "groupProvider is null"); this.statsCalculator = requireNonNull(statsCalculator, "statsCalculator is null"); @@ -68,9 +71,6 @@ public String getName() @Override public ListenableFuture execute( CreateView statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/DataDefinitionExecution.java b/core/trino-main/src/main/java/io/trino/execution/DataDefinitionExecution.java index 2a7400aef640..07b996c64791 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DataDefinitionExecution.java +++ b/core/trino-main/src/main/java/io/trino/execution/DataDefinitionExecution.java @@ -23,15 +23,12 @@ import io.trino.execution.StateMachine.StateChangeListener; import io.trino.execution.warnings.WarningCollector; import io.trino.memory.VersionedMemoryPoolId; -import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.server.BasicQueryInfo; import io.trino.server.protocol.Slug; import io.trino.spi.QueryId; import io.trino.sql.planner.Plan; import io.trino.sql.tree.Expression; import io.trino.sql.tree.Statement; -import io.trino.transaction.TransactionManager; import org.joda.time.DateTime; import javax.annotation.Nullable; @@ -54,9 +51,6 @@ public class DataDefinitionExecution private final DataDefinitionTask task; private final T statement; private final Slug slug; - private final TransactionManager transactionManager; - private final Metadata metadata; - private final AccessControl accessControl; private final QueryStateMachine stateMachine; private final List parameters; private final WarningCollector warningCollector; @@ -65,9 +59,6 @@ private DataDefinitionExecution( DataDefinitionTask task, T statement, Slug slug, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) @@ -75,9 +66,6 @@ private DataDefinitionExecution( this.task = requireNonNull(task, "task is null"); this.statement = requireNonNull(statement, "statement is null"); this.slug = requireNonNull(slug, "slug is null"); - this.transactionManager = requireNonNull(transactionManager, "transactionManager is null"); - this.metadata = requireNonNull(metadata, "metadata is null"); - this.accessControl = requireNonNull(accessControl, "accessControl is null"); this.stateMachine = requireNonNull(stateMachine, "stateMachine is null"); this.parameters = parameters; this.warningCollector = requireNonNull(warningCollector, "warningCollector is null"); @@ -167,7 +155,7 @@ public void start() return; } - ListenableFuture future = task.execute(statement, transactionManager, metadata, accessControl, stateMachine, parameters, warningCollector); + ListenableFuture future = task.execute(statement, stateMachine, parameters, warningCollector); Futures.addCallback(future, new FutureCallback<>() { @Override @@ -293,21 +281,11 @@ public List getParameters() public static class DataDefinitionExecutionFactory implements QueryExecutionFactory> { - private final TransactionManager transactionManager; - private final Metadata metadata; - private final AccessControl accessControl; private final Map, DataDefinitionTask> tasks; @Inject - public DataDefinitionExecutionFactory( - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, - Map, DataDefinitionTask> tasks) + public DataDefinitionExecutionFactory(Map, DataDefinitionTask> tasks) { - this.transactionManager = requireNonNull(transactionManager, "transactionManager is null"); - this.metadata = requireNonNull(metadata, "metadata is null"); - this.accessControl = requireNonNull(accessControl, "accessControl is null"); this.tasks = requireNonNull(tasks, "tasks is null"); } @@ -333,7 +311,7 @@ private DataDefinitionExecution createDataDefinitionExe checkArgument(task != null, "no task for statement: %s", statement.getClass().getSimpleName()); stateMachine.setUpdateType(task.getName()); - return new DataDefinitionExecution<>(task, statement, slug, transactionManager, metadata, accessControl, stateMachine, parameters, warningCollector); + return new DataDefinitionExecution<>(task, statement, slug, stateMachine, parameters, warningCollector); } } } diff --git a/core/trino-main/src/main/java/io/trino/execution/DataDefinitionTask.java b/core/trino-main/src/main/java/io/trino/execution/DataDefinitionTask.java index ffcca2ccf999..5b17b4dfc71c 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DataDefinitionTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DataDefinitionTask.java @@ -15,11 +15,8 @@ import com.google.common.util.concurrent.ListenableFuture; import io.trino.execution.warnings.WarningCollector; -import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.sql.tree.Expression; import io.trino.sql.tree.Statement; -import io.trino.transaction.TransactionManager; import java.util.List; @@ -29,9 +26,6 @@ public interface DataDefinitionTask ListenableFuture execute( T statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector); diff --git a/core/trino-main/src/main/java/io/trino/execution/DeallocateTask.java b/core/trino-main/src/main/java/io/trino/execution/DeallocateTask.java index 7fcfe7a422b4..3a3fe5f0f378 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DeallocateTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DeallocateTask.java @@ -15,11 +15,8 @@ import com.google.common.util.concurrent.ListenableFuture; import io.trino.execution.warnings.WarningCollector; -import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.sql.tree.Deallocate; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; import java.util.List; @@ -37,9 +34,6 @@ public String getName() @Override public ListenableFuture execute( Deallocate statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/DropColumnTask.java b/core/trino-main/src/main/java/io/trino/execution/DropColumnTask.java index c35a77be699f..0dbe3aed38f5 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DropColumnTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DropColumnTask.java @@ -23,7 +23,8 @@ import io.trino.spi.connector.ColumnHandle; import io.trino.sql.tree.DropColumn; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -35,10 +36,21 @@ import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class DropColumnTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public DropColumnTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -48,9 +60,6 @@ public String getName() @Override public ListenableFuture execute( DropColumn statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/DropMaterializedViewTask.java b/core/trino-main/src/main/java/io/trino/execution/DropMaterializedViewTask.java index c587d017f8cc..033c85beaeac 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DropMaterializedViewTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DropMaterializedViewTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.DropMaterializedView; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -31,10 +32,21 @@ import static io.trino.metadata.MetadataUtil.createQualifiedObjectName; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class DropMaterializedViewTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public DropMaterializedViewTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -44,9 +56,6 @@ public String getName() @Override public ListenableFuture execute( DropMaterializedView statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/DropRoleTask.java b/core/trino-main/src/main/java/io/trino/execution/DropRoleTask.java index d7fe9f4a8543..f5a71c21b289 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DropRoleTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DropRoleTask.java @@ -21,7 +21,8 @@ import io.trino.sql.tree.DropRole; import io.trino.sql.tree.Expression; import io.trino.sql.tree.Identifier; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -30,10 +31,21 @@ import static io.trino.metadata.MetadataUtil.checkRoleExists; import static io.trino.metadata.MetadataUtil.processRoleCommandCatalog; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class DropRoleTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public DropRoleTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -43,9 +55,6 @@ public String getName() @Override public ListenableFuture execute( DropRole statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/DropSchemaTask.java b/core/trino-main/src/main/java/io/trino/execution/DropSchemaTask.java index 4fa0a1b5f142..b7135ff714f7 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DropSchemaTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DropSchemaTask.java @@ -23,7 +23,8 @@ import io.trino.spi.connector.CatalogSchemaName; import io.trino.sql.tree.DropSchema; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -34,10 +35,21 @@ import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_EMPTY; import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class DropSchemaTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public DropSchemaTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -47,9 +59,6 @@ public String getName() @Override public ListenableFuture execute( DropSchema statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/DropTableTask.java b/core/trino-main/src/main/java/io/trino/execution/DropTableTask.java index f92ccc38a5bc..2b6b8bad049b 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DropTableTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DropTableTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.DropTable; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -31,10 +32,21 @@ import static io.trino.metadata.MetadataUtil.createQualifiedObjectName; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class DropTableTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public DropTableTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -44,9 +56,6 @@ public String getName() @Override public ListenableFuture execute( DropTable statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/DropViewTask.java b/core/trino-main/src/main/java/io/trino/execution/DropViewTask.java index 429fd577be10..4878d470eb52 100644 --- a/core/trino-main/src/main/java/io/trino/execution/DropViewTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/DropViewTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.DropView; import io.trino.sql.tree.Expression; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -31,10 +32,21 @@ import static io.trino.metadata.MetadataUtil.createQualifiedObjectName; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class DropViewTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public DropViewTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -44,9 +56,6 @@ public String getName() @Override public ListenableFuture execute( DropView statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/GrantRolesTask.java b/core/trino-main/src/main/java/io/trino/execution/GrantRolesTask.java index ed70aa9e5681..3cecf8db63ae 100644 --- a/core/trino-main/src/main/java/io/trino/execution/GrantRolesTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/GrantRolesTask.java @@ -23,7 +23,8 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.GrantRoles; import io.trino.sql.tree.Identifier; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.LinkedHashSet; import java.util.List; @@ -37,10 +38,21 @@ import static io.trino.metadata.MetadataUtil.createPrincipal; import static io.trino.metadata.MetadataUtil.processRoleCommandCatalog; import static io.trino.spi.security.PrincipalType.ROLE; +import static java.util.Objects.requireNonNull; public class GrantRolesTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public GrantRolesTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -50,9 +62,6 @@ public String getName() @Override public ListenableFuture execute( GrantRoles statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/GrantTask.java b/core/trino-main/src/main/java/io/trino/execution/GrantTask.java index 352791ef3872..c36ae1906c98 100644 --- a/core/trino-main/src/main/java/io/trino/execution/GrantTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/GrantTask.java @@ -25,7 +25,8 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.Grant; import io.trino.sql.tree.GrantOnType; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.EnumSet; import java.util.List; @@ -41,10 +42,21 @@ import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class GrantTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public GrantTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -54,23 +66,20 @@ public String getName() @Override public ListenableFuture execute( Grant statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) { if (statement.getType().filter(GrantOnType.SCHEMA::equals).isPresent()) { - executeGrantOnSchema(stateMachine.getSession(), statement, metadata, accessControl); + executeGrantOnSchema(stateMachine.getSession(), statement); } else { - executeGrantOnTable(stateMachine.getSession(), statement, metadata, accessControl); + executeGrantOnTable(stateMachine.getSession(), statement); } return immediateVoidFuture(); } - private void executeGrantOnSchema(Session session, Grant statement, Metadata metadata, AccessControl accessControl) + private void executeGrantOnSchema(Session session, Grant statement) { CatalogSchemaName schemaName = createCatalogSchemaName(session, statement, Optional.of(statement.getName())); @@ -86,7 +95,7 @@ private void executeGrantOnSchema(Session session, Grant statement, Metadata met metadata.grantSchemaPrivileges(session, schemaName, privileges, createPrincipal(statement.getGrantee()), statement.isWithGrantOption()); } - private void executeGrantOnTable(Session session, Grant statement, Metadata metadata, AccessControl accessControl) + private void executeGrantOnTable(Session session, Grant statement) { QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getName()); Optional tableHandle = metadata.getTableHandle(session, tableName); diff --git a/core/trino-main/src/main/java/io/trino/execution/PrepareTask.java b/core/trino-main/src/main/java/io/trino/execution/PrepareTask.java index 8bae393848ce..626ea60e86ef 100644 --- a/core/trino-main/src/main/java/io/trino/execution/PrepareTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/PrepareTask.java @@ -15,8 +15,6 @@ import com.google.common.util.concurrent.ListenableFuture; import io.trino.execution.warnings.WarningCollector; -import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.spi.TrinoException; import io.trino.sql.parser.SqlParser; import io.trino.sql.tree.Deallocate; @@ -24,7 +22,6 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.Prepare; import io.trino.sql.tree.Statement; -import io.trino.transaction.TransactionManager; import javax.inject.Inject; @@ -56,9 +53,6 @@ public String getName() @Override public ListenableFuture execute( Prepare prepare, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/RenameColumnTask.java b/core/trino-main/src/main/java/io/trino/execution/RenameColumnTask.java index a71d762df830..e6a2d19bf498 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RenameColumnTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RenameColumnTask.java @@ -23,7 +23,8 @@ import io.trino.spi.connector.ColumnHandle; import io.trino.sql.tree.Expression; import io.trino.sql.tree.RenameColumn; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Map; @@ -37,10 +38,21 @@ import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class RenameColumnTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public RenameColumnTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -50,9 +62,6 @@ public String getName() @Override public ListenableFuture execute( RenameColumn statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/RenameMaterializedViewTask.java b/core/trino-main/src/main/java/io/trino/execution/RenameMaterializedViewTask.java index 712c36bf19a0..28d35716951d 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RenameMaterializedViewTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RenameMaterializedViewTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.Expression; import io.trino.sql.tree.RenameMaterializedView; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -34,10 +35,21 @@ import static io.trino.spi.StandardErrorCode.TABLE_ALREADY_EXISTS; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class RenameMaterializedViewTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public RenameMaterializedViewTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -47,9 +59,6 @@ public String getName() @Override public ListenableFuture execute( RenameMaterializedView statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/RenameSchemaTask.java b/core/trino-main/src/main/java/io/trino/execution/RenameSchemaTask.java index bd66d1ab83ee..dd5827ddc688 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RenameSchemaTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RenameSchemaTask.java @@ -21,7 +21,8 @@ import io.trino.spi.connector.CatalogSchemaName; import io.trino.sql.tree.Expression; import io.trino.sql.tree.RenameSchema; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -31,10 +32,21 @@ import static io.trino.spi.StandardErrorCode.SCHEMA_ALREADY_EXISTS; import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class RenameSchemaTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public RenameSchemaTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -44,9 +56,6 @@ public String getName() @Override public ListenableFuture execute( RenameSchema statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java b/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java index 7cf9e6cd4dd7..824cf85103da 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.Expression; import io.trino.sql.tree.RenameTable; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -34,10 +35,21 @@ import static io.trino.spi.StandardErrorCode.TABLE_ALREADY_EXISTS; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class RenameTableTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public RenameTableTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -47,9 +59,6 @@ public String getName() @Override public ListenableFuture execute( RenameTable statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/RenameViewTask.java b/core/trino-main/src/main/java/io/trino/execution/RenameViewTask.java index c5bd8a9eb22b..5ee94b4f07e4 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RenameViewTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RenameViewTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.Expression; import io.trino.sql.tree.RenameView; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -34,10 +35,21 @@ import static io.trino.spi.StandardErrorCode.TABLE_ALREADY_EXISTS; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class RenameViewTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public RenameViewTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -47,9 +59,6 @@ public String getName() @Override public ListenableFuture execute( RenameView statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/ResetSessionTask.java b/core/trino-main/src/main/java/io/trino/execution/ResetSessionTask.java index 89acf28bc0f4..c7fe63c2fca8 100644 --- a/core/trino-main/src/main/java/io/trino/execution/ResetSessionTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/ResetSessionTask.java @@ -17,10 +17,10 @@ import io.trino.connector.CatalogName; import io.trino.execution.warnings.WarningCollector; import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.sql.tree.Expression; import io.trino.sql.tree.ResetSession; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; @@ -28,10 +28,19 @@ import static io.trino.spi.StandardErrorCode.CATALOG_NOT_FOUND; import static io.trino.spi.StandardErrorCode.INVALID_SESSION_PROPERTY; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class ResetSessionTask implements DataDefinitionTask { + private final Metadata metadata; + + @Inject + public ResetSessionTask(Metadata metadata) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + } + @Override public String getName() { @@ -41,9 +50,6 @@ public String getName() @Override public ListenableFuture execute( ResetSession statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/RevokeRolesTask.java b/core/trino-main/src/main/java/io/trino/execution/RevokeRolesTask.java index 207faf8de120..5e0e11abcb40 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RevokeRolesTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RevokeRolesTask.java @@ -23,7 +23,8 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.Identifier; import io.trino.sql.tree.RevokeRoles; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.LinkedHashSet; import java.util.List; @@ -37,10 +38,21 @@ import static io.trino.metadata.MetadataUtil.createPrincipal; import static io.trino.metadata.MetadataUtil.processRoleCommandCatalog; import static io.trino.spi.security.PrincipalType.ROLE; +import static java.util.Objects.requireNonNull; public class RevokeRolesTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public RevokeRolesTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -50,9 +62,6 @@ public String getName() @Override public ListenableFuture execute( RevokeRoles statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/RevokeTask.java b/core/trino-main/src/main/java/io/trino/execution/RevokeTask.java index 196e69407bce..f548d49089f9 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RevokeTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RevokeTask.java @@ -25,7 +25,8 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.GrantOnType; import io.trino.sql.tree.Revoke; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.EnumSet; import java.util.List; @@ -41,10 +42,21 @@ import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class RevokeTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public RevokeTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -54,23 +66,20 @@ public String getName() @Override public ListenableFuture execute( Revoke statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) { if (statement.getType().filter(GrantOnType.SCHEMA::equals).isPresent()) { - executeRevokeOnSchema(stateMachine.getSession(), statement, metadata, accessControl); + executeRevokeOnSchema(stateMachine.getSession(), statement); } else { - executeRevokeOnTable(stateMachine.getSession(), statement, metadata, accessControl); + executeRevokeOnTable(stateMachine.getSession(), statement); } return immediateVoidFuture(); } - private void executeRevokeOnSchema(Session session, Revoke statement, Metadata metadata, AccessControl accessControl) + private void executeRevokeOnSchema(Session session, Revoke statement) { CatalogSchemaName schemaName = createCatalogSchemaName(session, statement, Optional.of(statement.getName())); @@ -86,7 +95,7 @@ private void executeRevokeOnSchema(Session session, Revoke statement, Metadata m metadata.revokeSchemaPrivileges(session, schemaName, privileges, createPrincipal(statement.getGrantee()), statement.isGrantOptionFor()); } - private void executeRevokeOnTable(Session session, Revoke statement, Metadata metadata, AccessControl accessControl) + private void executeRevokeOnTable(Session session, Revoke statement) { QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getName()); Optional tableHandle = metadata.getTableHandle(session, tableName); diff --git a/core/trino-main/src/main/java/io/trino/execution/RollbackTask.java b/core/trino-main/src/main/java/io/trino/execution/RollbackTask.java index 74c4f39d5fab..51318e9708f9 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RollbackTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RollbackTask.java @@ -16,22 +16,31 @@ import com.google.common.util.concurrent.ListenableFuture; import io.trino.Session; import io.trino.execution.warnings.WarningCollector; -import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.spi.TrinoException; import io.trino.sql.tree.Expression; import io.trino.sql.tree.Rollback; import io.trino.transaction.TransactionId; import io.trino.transaction.TransactionManager; +import javax.inject.Inject; + import java.util.List; import static com.google.common.util.concurrent.Futures.immediateVoidFuture; import static io.trino.spi.StandardErrorCode.NOT_IN_TRANSACTION; +import static java.util.Objects.requireNonNull; public class RollbackTask implements DataDefinitionTask { + private final TransactionManager transactionManager; + + @Inject + public RollbackTask(TransactionManager transactionManager) + { + this.transactionManager = requireNonNull(transactionManager, "transactionManager is null"); + } + @Override public String getName() { @@ -41,9 +50,6 @@ public String getName() @Override public ListenableFuture execute( Rollback statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/SetPathTask.java b/core/trino-main/src/main/java/io/trino/execution/SetPathTask.java index 8c689e0ce8d0..f46240198c9f 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetPathTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetPathTask.java @@ -18,13 +18,13 @@ import io.trino.client.ClientCapabilities; import io.trino.execution.warnings.WarningCollector; import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.spi.TrinoException; import io.trino.sql.SqlPath; import io.trino.sql.SqlPathElement; import io.trino.sql.tree.Expression; import io.trino.sql.tree.SetPath; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -35,10 +35,19 @@ import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class SetPathTask implements DataDefinitionTask { + private final Metadata metadata; + + @Inject + public SetPathTask(Metadata metadata) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + } + @Override public String getName() { @@ -48,9 +57,6 @@ public String getName() @Override public ListenableFuture execute( SetPath statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/SetPropertiesTask.java b/core/trino-main/src/main/java/io/trino/execution/SetPropertiesTask.java index 7d35eab66e06..57d7df829382 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetPropertiesTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetPropertiesTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.Expression; import io.trino.sql.tree.SetProperties; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Map; @@ -36,10 +37,21 @@ import static io.trino.sql.NodeUtils.mapFromProperties; import static io.trino.sql.ParameterUtils.parameterExtractor; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class SetPropertiesTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public SetPropertiesTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -49,9 +61,6 @@ public String getName() @Override public ListenableFuture execute( SetProperties statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) @@ -71,7 +80,7 @@ public ListenableFuture execute( accessControl, parameterExtractor(statement, parameters), false); // skip setting of default properties since they should not be stored explicitly - setTableProperties(statement, tableName, metadata, accessControl, session, properties); + setTableProperties(statement, tableName, session, properties); } else { throw semanticException(NOT_SUPPORTED, statement, "Unsupported target type: %s", statement.getType()); @@ -80,7 +89,7 @@ public ListenableFuture execute( return immediateVoidFuture(); } - private void setTableProperties(SetProperties statement, QualifiedObjectName tableName, Metadata metadata, AccessControl accessControl, Session session, Map properties) + private void setTableProperties(SetProperties statement, QualifiedObjectName tableName, Session session, Map properties) { if (metadata.isMaterializedView(session, tableName)) { throw semanticException(NOT_SUPPORTED, statement, "Cannot set properties to a materialized view in ALTER TABLE"); diff --git a/core/trino-main/src/main/java/io/trino/execution/SetRoleTask.java b/core/trino-main/src/main/java/io/trino/execution/SetRoleTask.java index 198c1de4009d..e320eadd430a 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetRoleTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetRoleTask.java @@ -25,7 +25,8 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.Identifier; import io.trino.sql.tree.SetRole; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -38,10 +39,21 @@ import static io.trino.spi.security.PrincipalType.USER; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class SetRoleTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public SetRoleTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -51,9 +63,6 @@ public String getName() @Override public ListenableFuture execute( SetRole statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/SetSchemaAuthorizationTask.java b/core/trino-main/src/main/java/io/trino/execution/SetSchemaAuthorizationTask.java index 9b08e23fc657..886305e7dd51 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetSchemaAuthorizationTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetSchemaAuthorizationTask.java @@ -22,7 +22,8 @@ import io.trino.spi.security.TrinoPrincipal; import io.trino.sql.tree.Expression; import io.trino.sql.tree.SetSchemaAuthorization; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -33,10 +34,21 @@ import static io.trino.metadata.MetadataUtil.createPrincipal; import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class SetSchemaAuthorizationTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public SetSchemaAuthorizationTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -46,9 +58,6 @@ public String getName() @Override public ListenableFuture execute( SetSchemaAuthorization statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/SetSessionTask.java b/core/trino-main/src/main/java/io/trino/execution/SetSessionTask.java index 932ddd9f14a7..84e040eaa503 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetSessionTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetSessionTask.java @@ -26,7 +26,8 @@ import io.trino.sql.tree.Expression; import io.trino.sql.tree.QualifiedName; import io.trino.sql.tree.SetSession; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; @@ -38,10 +39,21 @@ import static io.trino.sql.ParameterUtils.parameterExtractor; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static java.lang.String.format; +import static java.util.Objects.requireNonNull; public class SetSessionTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public SetSessionTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -51,9 +63,6 @@ public String getName() @Override public ListenableFuture execute( SetSession statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/SetTableAuthorizationTask.java b/core/trino-main/src/main/java/io/trino/execution/SetTableAuthorizationTask.java index 37365e7dc0b0..f3e77a7879b0 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetTableAuthorizationTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetTableAuthorizationTask.java @@ -22,7 +22,8 @@ import io.trino.spi.security.TrinoPrincipal; import io.trino.sql.tree.Expression; import io.trino.sql.tree.SetTableAuthorization; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -34,10 +35,21 @@ import static io.trino.metadata.MetadataUtil.getRequiredCatalogHandle; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class SetTableAuthorizationTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public SetTableAuthorizationTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -47,9 +59,6 @@ public String getName() @Override public ListenableFuture execute( SetTableAuthorization statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/SetTimeZoneTask.java b/core/trino-main/src/main/java/io/trino/execution/SetTimeZoneTask.java index 7e7359000fa2..d4e3bf5db620 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetTimeZoneTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetTimeZoneTask.java @@ -43,7 +43,6 @@ import io.trino.sql.tree.FunctionCall; import io.trino.sql.tree.NodeRef; import io.trino.sql.tree.SetTimeZone; -import io.trino.transaction.TransactionManager; import io.trino.type.IntervalDayTimeType; import javax.inject.Inject; @@ -68,13 +67,17 @@ public class SetTimeZoneTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; private final SqlParser sqlParser; private final GroupProvider groupProvider; private final StatsCalculator statsCalculator; @Inject - public SetTimeZoneTask(SqlParser sqlParser, GroupProvider groupProvider, StatsCalculator statsCalculator) + public SetTimeZoneTask(Metadata metadata, AccessControl accessControl, SqlParser sqlParser, GroupProvider groupProvider, StatsCalculator statsCalculator) { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); this.sqlParser = requireNonNull(sqlParser, "sqlParser is null"); this.groupProvider = requireNonNull(groupProvider, "groupProvider is null"); this.statsCalculator = requireNonNull(statsCalculator, "statsCalculator is null"); @@ -89,15 +92,12 @@ public String getName() @Override public ListenableFuture execute( SetTimeZone statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) { String timeZoneId = statement.getTimeZone() - .map(timeZone -> getTimeZoneId(timeZone, statement, metadata, accessControl, stateMachine, parameters, warningCollector)) + .map(timeZone -> getTimeZoneId(timeZone, statement, stateMachine, parameters, warningCollector)) .orElse(TimeZone.getDefault().getID()); stateMachine.addSetSessionProperties(TIME_ZONE_ID, timeZoneId); @@ -107,8 +107,6 @@ public ListenableFuture execute( private String getTimeZoneId( Expression expression, SetTimeZone statement, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/SetViewAuthorizationTask.java b/core/trino-main/src/main/java/io/trino/execution/SetViewAuthorizationTask.java index 720b9b8c1977..ef08f92a8b52 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SetViewAuthorizationTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/SetViewAuthorizationTask.java @@ -22,7 +22,8 @@ import io.trino.spi.security.TrinoPrincipal; import io.trino.sql.tree.Expression; import io.trino.sql.tree.SetViewAuthorization; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -34,10 +35,21 @@ import static io.trino.metadata.MetadataUtil.getRequiredCatalogHandle; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class SetViewAuthorizationTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public SetViewAuthorizationTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -47,9 +59,6 @@ public String getName() @Override public ListenableFuture execute( SetViewAuthorization statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/StartTransactionTask.java b/core/trino-main/src/main/java/io/trino/execution/StartTransactionTask.java index 7248cc2f8da0..3fed5a48f845 100644 --- a/core/trino-main/src/main/java/io/trino/execution/StartTransactionTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/StartTransactionTask.java @@ -16,8 +16,6 @@ import com.google.common.util.concurrent.ListenableFuture; import io.trino.Session; import io.trino.execution.warnings.WarningCollector; -import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.spi.StandardErrorCode; import io.trino.spi.TrinoException; import io.trino.spi.transaction.IsolationLevel; @@ -28,16 +26,27 @@ import io.trino.transaction.TransactionId; import io.trino.transaction.TransactionManager; +import javax.inject.Inject; + import java.util.List; import java.util.Optional; import static com.google.common.util.concurrent.Futures.immediateVoidFuture; import static io.trino.spi.StandardErrorCode.SYNTAX_ERROR; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class StartTransactionTask implements DataDefinitionTask { + private final TransactionManager transactionManager; + + @Inject + public StartTransactionTask(TransactionManager transactionManager) + { + this.transactionManager = requireNonNull(transactionManager, "transactionManager is null"); + } + @Override public String getName() { @@ -47,9 +56,6 @@ public String getName() @Override public ListenableFuture execute( StartTransaction statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/TruncateTableTask.java b/core/trino-main/src/main/java/io/trino/execution/TruncateTableTask.java index 797bc620e774..1303913033b8 100644 --- a/core/trino-main/src/main/java/io/trino/execution/TruncateTableTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/TruncateTableTask.java @@ -22,7 +22,8 @@ import io.trino.security.AccessControl; import io.trino.sql.tree.Expression; import io.trino.sql.tree.TruncateTable; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; import java.util.Optional; @@ -32,10 +33,21 @@ import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.spi.StandardErrorCode.TABLE_NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; +import static java.util.Objects.requireNonNull; public class TruncateTableTask implements DataDefinitionTask { + private final Metadata metadata; + private final AccessControl accessControl; + + @Inject + public TruncateTableTask(Metadata metadata, AccessControl accessControl) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + this.accessControl = requireNonNull(accessControl, "accessControl is null"); + } + @Override public String getName() { @@ -45,9 +57,6 @@ public String getName() @Override public ListenableFuture execute( TruncateTable statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/main/java/io/trino/execution/UseTask.java b/core/trino-main/src/main/java/io/trino/execution/UseTask.java index 00eddad8d013..0a6d6cc3a4bd 100644 --- a/core/trino-main/src/main/java/io/trino/execution/UseTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/UseTask.java @@ -17,12 +17,12 @@ import io.trino.Session; import io.trino.execution.warnings.WarningCollector; import io.trino.metadata.Metadata; -import io.trino.security.AccessControl; import io.trino.spi.TrinoException; import io.trino.spi.connector.CatalogSchemaName; import io.trino.sql.tree.Expression; import io.trino.sql.tree.Use; -import io.trino.transaction.TransactionManager; + +import javax.inject.Inject; import java.util.List; @@ -31,10 +31,19 @@ import static io.trino.spi.StandardErrorCode.NOT_FOUND; import static io.trino.sql.analyzer.SemanticExceptions.semanticException; import static java.util.Locale.ENGLISH; +import static java.util.Objects.requireNonNull; public class UseTask implements DataDefinitionTask { + private final Metadata metadata; + + @Inject + public UseTask(Metadata metadata) + { + this.metadata = requireNonNull(metadata, "metadata is null"); + } + @Override public String getName() { @@ -44,9 +53,6 @@ public String getName() @Override public ListenableFuture execute( Use statement, - TransactionManager transactionManager, - Metadata metadata, - AccessControl accessControl, QueryStateMachine stateMachine, List parameters, WarningCollector warningCollector) diff --git a/core/trino-main/src/test/java/io/trino/execution/TestCallTask.java b/core/trino-main/src/test/java/io/trino/execution/TestCallTask.java index 076aa240ce05..ba80dd0beefe 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestCallTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestCallTask.java @@ -130,12 +130,9 @@ private void executeCallTask(MethodHandle methodHandle, Function getFutureValue(new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP))) + () -> getFutureValue(new CommitTask(transactionManager).execute(new Commit(), stateMachine, emptyList(), WarningCollector.NOOP))) .hasErrorCode(NOT_IN_TRANSACTION); assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()); @@ -110,7 +109,7 @@ public void testUnknownTransactionCommit() .build(); QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, transactionManager); - Future future = new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP); + Future future = new CommitTask(transactionManager).execute(new Commit(), stateMachine, emptyList(), WarningCollector.NOOP); assertTrinoExceptionThrownBy(() -> getFutureValue(future)) .hasErrorCode(UNKNOWN_TRANSACTION); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java b/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java index 0022b7575d9e..6809c253d72e 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java @@ -143,8 +143,8 @@ public void testCreateMaterializedViewIfNotExists() ImmutableList.of(), Optional.empty()); - getFutureValue(new CreateMaterializedViewTask(parser, new TestingGroupProvider(), statsCalculator) - .execute(statement, transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP)); + getFutureValue(new CreateMaterializedViewTask(metadata, new AllowAllAccessControl(), parser, new TestingGroupProvider(), statsCalculator) + .execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP)); assertEquals(metadata.getCreateMaterializedViewCallCount(), 1); } @@ -160,8 +160,8 @@ public void testCreateMaterializedViewWithExistingView() ImmutableList.of(), Optional.empty()); - assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(parser, new TestingGroupProvider(), statsCalculator) - .execute(statement, transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))) + assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(metadata, new AllowAllAccessControl(), parser, new TestingGroupProvider(), statsCalculator) + .execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))) .hasErrorCode(ALREADY_EXISTS) .hasMessage("Materialized view already exists"); @@ -180,8 +180,8 @@ public void testCreateMaterializedViewWithInvalidProperty() ImmutableList.of(new Property(new Identifier("baz"), new StringLiteral("abc"))), Optional.empty()); - assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(parser, new TestingGroupProvider(), statsCalculator) - .execute(statement, transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))) + assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(metadata, new AllowAllAccessControl(), parser, new TestingGroupProvider(), statsCalculator) + .execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))) .hasErrorCode(INVALID_MATERIALIZED_VIEW_PROPERTY) .hasMessage("Catalog 'catalog' does not support materialized view property 'baz'"); @@ -203,8 +203,8 @@ public void testCreateDenyPermission() accessControl.loadSystemAccessControl(AllowAllSystemAccessControl.NAME, ImmutableMap.of()); accessControl.deny(privilege("test_mv", CREATE_MATERIALIZED_VIEW)); - assertThatThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(parser, new TestingGroupProvider(), statsCalculator) - .execute(statement, transactionManager, metadata, accessControl, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))) + assertThatThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(metadata, accessControl, parser, new TestingGroupProvider(), statsCalculator) + .execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))) .isInstanceOf(AccessDeniedException.class) .hasMessageContaining("Cannot create materialized view catalog.schema.test_mv"); } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestCreateTableTask.java b/core/trino-main/src/test/java/io/trino/execution/TestCreateTableTask.java index 51e390339341..b36f06712f45 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestCreateTableTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestCreateTableTask.java @@ -145,7 +145,7 @@ public void testCreateTableNotExistsTrue() ImmutableList.of(), Optional.empty()); - getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList(), output -> {})); + getFutureValue(new CreateTableTask(metadata, new AllowAllAccessControl(), new FeaturesConfig()).internalExecute(statement, testSession, emptyList(), output -> {})); assertEquals(metadata.getCreateTableCallCount(), 1); } @@ -158,7 +158,7 @@ public void testCreateTableNotExistsFalse() ImmutableList.of(), Optional.empty()); - assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList(), output -> {}))) + assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateTableTask(metadata, new AllowAllAccessControl(), new FeaturesConfig()).internalExecute(statement, testSession, emptyList(), output -> {}))) .hasErrorCode(ALREADY_EXISTS) .hasMessage("Table already exists"); @@ -174,7 +174,7 @@ public void testCreateTableWithMaterializedViewPropertyFails() ImmutableList.of(new Property(new Identifier("foo"), new StringLiteral("bar"))), Optional.empty()); - assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList(), output -> {}))) + assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateTableTask(metadata, new AllowAllAccessControl(), new FeaturesConfig()).internalExecute(statement, testSession, emptyList(), output -> {}))) .hasErrorCode(INVALID_TABLE_PROPERTY) .hasMessage("Catalog 'catalog' does not support table property 'foo'"); @@ -191,7 +191,7 @@ public void testCreateWithNotNullColumns() new ColumnDefinition(identifier("c"), toSqlType(VARBINARY), false, emptyList(), Optional.empty())); CreateTable statement = new CreateTable(QualifiedName.of("test_table"), inputColumns, true, ImmutableList.of(), Optional.empty()); - getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList(), output -> {})); + getFutureValue(new CreateTableTask(metadata, new AllowAllAccessControl(), new FeaturesConfig()).internalExecute(statement, testSession, emptyList(), output -> {})); assertEquals(metadata.getCreateTableCallCount(), 1); List columns = metadata.getReceivedTableMetadata().get(0).getColumns(); assertEquals(columns.size(), 3); @@ -224,7 +224,7 @@ public void testCreateWithUnsupportedConnectorThrowsWhenNotNull() Optional.empty()); assertTrinoExceptionThrownBy(() -> - getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList(), output -> {}))) + getFutureValue(new CreateTableTask(metadata, new AllowAllAccessControl(), new FeaturesConfig()).internalExecute(statement, testSession, emptyList(), output -> {}))) .hasErrorCode(NOT_SUPPORTED) .hasMessage("Catalog 'catalog' does not support non-null column for column name 'b'"); } @@ -234,7 +234,7 @@ public void testCreateLike() { CreateTable statement = getCreatleLikeStatement(false); - getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, List.of(), output -> {})); + getFutureValue(new CreateTableTask(metadata, new AllowAllAccessControl(), new FeaturesConfig()).internalExecute(statement, testSession, List.of(), output -> {})); assertEquals(metadata.getCreateTableCallCount(), 1); assertThat(metadata.getReceivedTableMetadata().get(0).getColumns()) @@ -247,7 +247,7 @@ public void testCreateLikeWithProperties() { CreateTable statement = getCreatleLikeStatement(true); - getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, List.of(), output -> {})); + getFutureValue(new CreateTableTask(metadata, new AllowAllAccessControl(), new FeaturesConfig()).internalExecute(statement, testSession, List.of(), output -> {})); assertEquals(metadata.getCreateTableCallCount(), 1); assertThat(metadata.getReceivedTableMetadata().get(0).getColumns()) @@ -264,7 +264,7 @@ public void testCreateLikeDenyPermission() TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, new EventListenerManager(new EventListenerConfig())); accessControl.deny(privilege("parent_table", SELECT_COLUMN)); - assertThatThrownBy(() -> getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, accessControl, testSession, List.of(), output -> {}))) + assertThatThrownBy(() -> getFutureValue(new CreateTableTask(metadata, accessControl, new FeaturesConfig()).internalExecute(statement, testSession, List.of(), output -> {}))) .isInstanceOf(AccessDeniedException.class) .hasMessageContaining("Cannot reference columns of table"); } @@ -277,7 +277,7 @@ public void testCreateLikeWithPropertiesDenyPermission() TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, new EventListenerManager(new EventListenerConfig())); accessControl.deny(privilege("parent_table", SHOW_CREATE_TABLE)); - assertThatThrownBy(() -> getFutureValue(new CreateTableTask(new FeaturesConfig()).internalExecute(statement, metadata, accessControl, testSession, List.of(), output -> {}))) + assertThatThrownBy(() -> getFutureValue(new CreateTableTask(metadata, accessControl, new FeaturesConfig()).internalExecute(statement, testSession, List.of(), output -> {}))) .isInstanceOf(AccessDeniedException.class) .hasMessageContaining("Cannot reference properties of table"); } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestDeallocateTask.java b/core/trino-main/src/test/java/io/trino/execution/TestDeallocateTask.java index 57a677128630..4f0a6a8f2f5b 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestDeallocateTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestDeallocateTask.java @@ -21,7 +21,6 @@ import io.trino.plugin.base.security.DefaultSystemAccessControl; import io.trino.security.AccessControlConfig; import io.trino.security.AccessControlManager; -import io.trino.security.AllowAllAccessControl; import io.trino.spi.resourcegroups.ResourceGroupId; import io.trino.sql.tree.Deallocate; import io.trino.sql.tree.Identifier; @@ -96,7 +95,7 @@ private Set executeDeallocate(String statementName, String sqlString, Se WarningCollector.NOOP, Optional.empty()); Deallocate deallocate = new Deallocate(new Identifier(statementName)); - new DeallocateTask().execute(deallocate, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP); + new DeallocateTask().execute(deallocate, stateMachine, emptyList(), WarningCollector.NOOP); return stateMachine.getDeallocatedPreparedStatements(); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestDropMaterializedViewTask.java b/core/trino-main/src/test/java/io/trino/execution/TestDropMaterializedViewTask.java index b288cd40de27..4af5002b33aa 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestDropMaterializedViewTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestDropMaterializedViewTask.java @@ -105,6 +105,7 @@ public void testDropMaterializedViewOnViewIfExists() private ListenableFuture executeDropMaterializedView(QualifiedName viewName, boolean exists) { - return new DropMaterializedViewTask().execute(new DropMaterializedView(viewName, exists), transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); + return new DropMaterializedViewTask(metadata, new AllowAllAccessControl()) + .execute(new DropMaterializedView(viewName, exists), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestDropTableTask.java b/core/trino-main/src/test/java/io/trino/execution/TestDropTableTask.java index fdbfce2e9a65..70597df3f409 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestDropTableTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestDropTableTask.java @@ -105,6 +105,6 @@ public void testDropTableOnMaterializedViewIfExists() private ListenableFuture executeDropTable(QualifiedName tableName, boolean exists) { - return new DropTableTask().execute(new DropTable(tableName, exists), transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); + return new DropTableTask(metadata, new AllowAllAccessControl()).execute(new DropTable(tableName, exists), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestDropViewTask.java b/core/trino-main/src/test/java/io/trino/execution/TestDropViewTask.java index ddd73eb87143..630f90c65def 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestDropViewTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestDropViewTask.java @@ -105,6 +105,6 @@ public void testDropViewOnMaterializedViewIfExists() private ListenableFuture executeDropView(QualifiedName viewName, boolean exists) { - return new DropViewTask().execute(new DropView(viewName, exists), transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); + return new DropViewTask(metadata, new AllowAllAccessControl()).execute(new DropView(viewName, exists), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestPrepareTask.java b/core/trino-main/src/test/java/io/trino/execution/TestPrepareTask.java index 61c82a1d7e67..310d7fb49c69 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestPrepareTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestPrepareTask.java @@ -21,7 +21,6 @@ import io.trino.plugin.base.security.DefaultSystemAccessControl; import io.trino.security.AccessControlConfig; import io.trino.security.AccessControlManager; -import io.trino.security.AllowAllAccessControl; import io.trino.spi.resourcegroups.ResourceGroupId; import io.trino.sql.parser.SqlParser; import io.trino.sql.tree.AllColumns; @@ -119,7 +118,7 @@ private Map executePrepare(String statementName, Statement state WarningCollector.NOOP, Optional.empty()); Prepare prepare = new Prepare(identifier(statementName), statement); - new PrepareTask(new SqlParser()).execute(prepare, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP); + new PrepareTask(new SqlParser()).execute(prepare, stateMachine, emptyList(), WarningCollector.NOOP); return stateMachine.getAddedPreparedStatements(); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestRenameMaterializedViewTask.java b/core/trino-main/src/test/java/io/trino/execution/TestRenameMaterializedViewTask.java index 0cce041518d9..1e41b8325de8 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestRenameMaterializedViewTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestRenameMaterializedViewTask.java @@ -140,6 +140,7 @@ private ListenableFuture executeRenameMaterializedView(QualifiedName sourc private ListenableFuture executeRenameMaterializedView(QualifiedName source, QualifiedName target, boolean exists) { - return new RenameMaterializedViewTask().execute(new RenameMaterializedView(source, target, exists), transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); + return new RenameMaterializedViewTask(metadata, new AllowAllAccessControl()) + .execute(new RenameMaterializedView(source, target, exists), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestRenameTableTask.java b/core/trino-main/src/test/java/io/trino/execution/TestRenameTableTask.java index f80524559610..63733b8d2df0 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestRenameTableTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestRenameTableTask.java @@ -106,6 +106,7 @@ public void testRenameTableOnMaterializedViewIfExists() private ListenableFuture executeRenameTable(QualifiedName source, QualifiedName target, boolean exists) { - return new RenameTableTask().execute(new RenameTable(source, target, exists), transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); + return new RenameTableTask(metadata, new AllowAllAccessControl()) + .execute(new RenameTable(source, target, exists), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestRenameViewTask.java b/core/trino-main/src/test/java/io/trino/execution/TestRenameViewTask.java index 8fce36059d25..eba2e5d63610 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestRenameViewTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestRenameViewTask.java @@ -77,6 +77,7 @@ public void testRenameViewOnMaterializedView() private ListenableFuture executeRenameView(QualifiedName source, QualifiedName target) { - return new RenameViewTask().execute(new RenameView(source, target), transactionManager, metadata, new AllowAllAccessControl(), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); + return new RenameViewTask(metadata, new AllowAllAccessControl()) + .execute(new RenameView(source, target), queryStateMachine, ImmutableList.of(), WarningCollector.NOOP); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestResetSessionTask.java b/core/trino-main/src/test/java/io/trino/execution/TestResetSessionTask.java index 6ef6ce11b058..0624b41d26c0 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestResetSessionTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestResetSessionTask.java @@ -106,11 +106,8 @@ public void test() WarningCollector.NOOP, Optional.empty()); - getFutureValue(new ResetSessionTask().execute( + getFutureValue(new ResetSessionTask(metadata).execute( new ResetSession(QualifiedName.of(CATALOG_NAME, "baz")), - transactionManager, - metadata, - accessControl, stateMachine, emptyList(), WarningCollector.NOOP)); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestRollbackTask.java b/core/trino-main/src/test/java/io/trino/execution/TestRollbackTask.java index 10e61ed8e263..9472f42eeda1 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestRollbackTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestRollbackTask.java @@ -69,7 +69,7 @@ public void testRollback() assertTrue(stateMachine.getSession().getTransactionId().isPresent()); assertEquals(transactionManager.getAllTransactionInfos().size(), 1); - getFutureValue(new RollbackTask().execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP)); + getFutureValue(new RollbackTask(transactionManager).execute(new Rollback(), stateMachine, emptyList(), WarningCollector.NOOP)); assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()); assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent()); @@ -86,7 +86,7 @@ public void testNoTransactionRollback() QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, transactionManager); assertTrinoExceptionThrownBy( - () -> getFutureValue((Future) new RollbackTask().execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP))) + () -> getFutureValue((Future) new RollbackTask(transactionManager).execute(new Rollback(), stateMachine, emptyList(), WarningCollector.NOOP))) .hasErrorCode(NOT_IN_TRANSACTION); assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()); @@ -105,7 +105,7 @@ public void testUnknownTransactionRollback() .build(); QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, transactionManager); - getFutureValue(new RollbackTask().execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP)); + getFutureValue(new RollbackTask(transactionManager).execute(new Rollback(), stateMachine, emptyList(), WarningCollector.NOOP)); assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()); // Still issue clear signal assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent()); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestSetPathTask.java b/core/trino-main/src/test/java/io/trino/execution/TestSetPathTask.java index 6ba022d91167..b450ced75c15 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestSetPathTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestSetPathTask.java @@ -112,11 +112,8 @@ private QueryStateMachine createQueryStateMachine(String query) private void executeSetPathTask(PathSpecification pathSpecification, QueryStateMachine stateMachine) { - getFutureValue(new SetPathTask().execute( + getFutureValue(new SetPathTask(metadata).execute( new SetPath(pathSpecification), - transactionManager, - metadata, - accessControl, stateMachine, emptyList(), WarningCollector.NOOP)); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestSetRoleTask.java b/core/trino-main/src/test/java/io/trino/execution/TestSetRoleTask.java index 82cdc9259d6b..4206c5a1b28b 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestSetRoleTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestSetRoleTask.java @@ -204,7 +204,7 @@ private QueryStateMachine executeSetRole(String statement) metadata, WarningCollector.NOOP, Optional.empty()); - new SetRoleTask().execute(setRole, transactionManager, metadata, accessControl, stateMachine, ImmutableList.of(), WarningCollector.NOOP); + new SetRoleTask(metadata, accessControl).execute(setRole, stateMachine, ImmutableList.of(), WarningCollector.NOOP); return stateMachine; } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestSetSessionTask.java b/core/trino-main/src/test/java/io/trino/execution/TestSetSessionTask.java index 906aad6173af..1f34f0459c09 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestSetSessionTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestSetSessionTask.java @@ -198,7 +198,7 @@ private void testSetSessionWithParameters(String property, Expression expression metadata, WarningCollector.NOOP, Optional.empty()); - getFutureValue(new SetSessionTask().execute(new SetSession(qualifiedPropName, expression), transactionManager, metadata, accessControl, stateMachine, parameters, WarningCollector.NOOP)); + getFutureValue(new SetSessionTask(metadata, accessControl).execute(new SetSession(qualifiedPropName, expression), stateMachine, parameters, WarningCollector.NOOP)); Map sessionProperties = stateMachine.getSetSessionProperties(); assertEquals(sessionProperties, ImmutableMap.of(qualifiedPropName.toString(), expectedValue)); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestSetTimeZoneTask.java b/core/trino-main/src/test/java/io/trino/execution/TestSetTimeZoneTask.java index 28a91e95806a..24557507f4b5 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestSetTimeZoneTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestSetTimeZoneTask.java @@ -255,14 +255,12 @@ private QueryStateMachine createQueryStateMachine(String query) private void executeSetTimeZone(SetTimeZone setTimeZone, QueryStateMachine stateMachine) { - getFutureValue(new SetTimeZoneTask(localQueryRunner.getSqlParser(), localQueryRunner.getGroupProvider(), localQueryRunner.getStatsCalculator()) - .execute( - setTimeZone, - localQueryRunner.getTransactionManager(), - localQueryRunner.getMetadata(), - localQueryRunner.getAccessControl(), - stateMachine, - emptyList(), - WarningCollector.NOOP)); + SetTimeZoneTask task = new SetTimeZoneTask( + localQueryRunner.getMetadata(), + localQueryRunner.getAccessControl(), + localQueryRunner.getSqlParser(), + localQueryRunner.getGroupProvider(), + localQueryRunner.getStatsCalculator()); + getFutureValue(task.execute(setTimeZone, stateMachine, emptyList(), WarningCollector.NOOP)); } } diff --git a/core/trino-main/src/test/java/io/trino/execution/TestStartTransactionTask.java b/core/trino-main/src/test/java/io/trino/execution/TestStartTransactionTask.java index f38bb111fa20..401e804fb9d8 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestStartTransactionTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestStartTransactionTask.java @@ -23,7 +23,6 @@ import io.trino.plugin.base.security.DefaultSystemAccessControl; import io.trino.security.AccessControlConfig; import io.trino.security.AccessControlManager; -import io.trino.security.AllowAllAccessControl; import io.trino.spi.resourcegroups.ResourceGroupId; import io.trino.spi.transaction.IsolationLevel; import io.trino.sql.tree.Isolation; @@ -40,7 +39,6 @@ import java.net.URI; import java.util.Optional; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -85,7 +83,8 @@ public void testNonTransactionalClient() assertFalse(stateMachine.getSession().getTransactionId().isPresent()); assertTrinoExceptionThrownBy( - () -> getFutureValue((Future) new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP))) + () -> getFutureValue(new StartTransactionTask(transactionManager) + .execute(new StartTransaction(ImmutableList.of()), stateMachine, emptyList(), WarningCollector.NOOP))) .hasErrorCode(INCOMPATIBLE_CLIENT); assertTrue(transactionManager.getAllTransactionInfos().isEmpty()); @@ -105,7 +104,8 @@ public void testNestedTransaction() QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager); assertTrinoExceptionThrownBy( - () -> getFutureValue((Future) new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP))) + () -> getFutureValue(new StartTransactionTask(transactionManager) + .execute(new StartTransaction(ImmutableList.of()), stateMachine, emptyList(), WarningCollector.NOOP))) .hasErrorCode(NOT_SUPPORTED); assertTrue(transactionManager.getAllTransactionInfos().isEmpty()); @@ -124,7 +124,7 @@ public void testStartTransaction() QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager); assertFalse(stateMachine.getSession().getTransactionId().isPresent()); - getFutureValue(new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP)); + getFutureValue(new StartTransactionTask(transactionManager).execute(new StartTransaction(ImmutableList.of()), stateMachine, emptyList(), WarningCollector.NOOP)); assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId()); assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent()); assertEquals(transactionManager.getAllTransactionInfos().size(), 1); @@ -143,11 +143,8 @@ public void testStartTransactionExplicitModes() QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager); assertFalse(stateMachine.getSession().getTransactionId().isPresent()); - getFutureValue(new StartTransactionTask().execute( + getFutureValue(new StartTransactionTask(transactionManager).execute( new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), - transactionManager, - metadata, - new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP)); @@ -172,11 +169,8 @@ public void testStartTransactionTooManyIsolationLevels() assertFalse(stateMachine.getSession().getTransactionId().isPresent()); assertTrinoExceptionThrownBy(() -> - getFutureValue(new StartTransactionTask().execute( + getFutureValue(new StartTransactionTask(transactionManager).execute( new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.READ_COMMITTED), new Isolation(Isolation.Level.READ_COMMITTED))), - transactionManager, - metadata, - new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP))) @@ -199,11 +193,8 @@ public void testStartTransactionTooManyAccessModes() assertFalse(stateMachine.getSession().getTransactionId().isPresent()); assertTrinoExceptionThrownBy(() -> - getFutureValue(new StartTransactionTask().execute( + getFutureValue(new StartTransactionTask(transactionManager).execute( new StartTransaction(ImmutableList.of(new TransactionAccessMode(true), new TransactionAccessMode(true))), - transactionManager, - metadata, - new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP))) @@ -232,11 +223,8 @@ public void testStartTransactionIdleExpiration() QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager); assertFalse(stateMachine.getSession().getTransactionId().isPresent()); - getFutureValue(new StartTransactionTask().execute( + getFutureValue(new StartTransactionTask(transactionManager).execute( new StartTransaction(ImmutableList.of()), - transactionManager, - metadata, - new AllowAllAccessControl(), stateMachine, emptyList(), WarningCollector.NOOP));