xtern commented on code in PR #4706: URL: https://github.com/apache/ignite-3/pull/4706#discussion_r1850482210
########## modules/sql-engine/src/testFixtures/java/org/apache/ignite/internal/sql/engine/util/SqlTestUtils.java: ########## @@ -558,4 +560,23 @@ public static void executeUpdate(String query, IgniteSql sql, @Nullable Transact public static void executeUpdate(String query, IgniteSql sql) { executeUpdate(query, sql, null); } + + /** The action is expected to throw a {@link SqlException} with code {@link Sql#EXECUTION_CANCELLED_ERR}. */ + public static void expectQueryCancelled(Executable action) { + assertThrowsSqlException( + Sql.EXECUTION_CANCELLED_ERR, + "The query was cancelled while executing.", + action + ); + } + + /** The action is expected to throw a {@link QueryCancelledException}. */ + public static void expectQueryCancelledInternalException(Executable action) { + //noinspection ThrowableNotThrown + IgniteTestUtils.assertThrows( + QueryCancelledException.class, + action, + "The query was cancelled while executing." Review Comment: Fixed, thanks. ########## modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlSynchronousApiTest.java: ########## @@ -74,8 +75,23 @@ public void cancelQueryString() throws InterruptedException { .build(); Transaction transaction = igniteTx().begin(); + + transactions.add(transaction); + return sql.execute(transaction, token, statement); }); + + // Checks the exception that is thrown if a query is canceled before a cursor is obtained. + CancelHandle cancelHandle = CancelHandle.create(); + CancellationToken token = cancelHandle.token(); + cancelHandle.cancel(); + + //noinspection resource + assertThrowsSqlException( + Sql.EXECUTION_CANCELLED_ERR, + "The query was cancelled while executing.", Review Comment: Fixed, thanks. ########## modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCancelQueryTest.java: ########## @@ -18,30 +18,29 @@ package org.apache.ignite.internal.sql.engine; import static org.apache.ignite.internal.sql.engine.QueryProperty.ALLOWED_QUERY_TYPES; +import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.expectQueryCancelled; +import static org.apache.ignite.internal.sql.engine.util.SqlTestUtils.expectQueryCancelledInternalException; +import static org.apache.ignite.internal.testframework.IgniteTestUtils.await; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Set; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; import org.apache.ignite.internal.TestWrappers; import org.apache.ignite.internal.app.IgniteImpl; import org.apache.ignite.internal.sql.BaseSqlIntegrationTest; import org.apache.ignite.internal.sql.engine.property.SqlProperties; import org.apache.ignite.internal.sql.engine.property.SqlPropertiesHelper; import org.apache.ignite.internal.tx.HybridTimestampTracker; -import org.apache.ignite.internal.util.AsyncCursor.BatchedResult; import org.apache.ignite.lang.CancelHandle; import org.apache.ignite.lang.CancellationToken; -import org.apache.ignite.lang.ErrorGroups.Sql; -import org.apache.ignite.sql.SqlException; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; /** Set of test cases for query cancellation. */ -public class ItQueryCancelTest extends BaseSqlIntegrationTest { +public class ItCancelQueryTest extends BaseSqlIntegrationTest { + private static final String QUERY_CANCELED_ERR = "The query was cancelled while executing"; Review Comment: Fixed, thanks. ########## modules/api/src/main/java/org/apache/ignite/sql/IgniteSql.java: ########## @@ -379,6 +379,16 @@ <T> CompletableFuture<AsyncResultSet<T>> executeAsync( */ void executeScript(String query, @Nullable Object... arguments); + /** + * Executes a multi-statement SQL query. + * + * @param cancellationToken Cancellation token or {@code null}. + * @param query SQL query template. + * @param arguments Arguments for the template (optional). + * @throws SqlException If failed. + */ + void executeScript(@Nullable CancellationToken cancellationToken, String query, @Nullable Object... arguments); Review Comment: As far as I understand, we use the practice of separating Nullable parameters from varargs. For example: ``` ResultSet<SqlRow> execute( @Nullable Transaction transaction, @Nullable CancellationToken cancellationToken, String query, @Nullable Object... arguments ); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org