korlov42 commented on code in PR #6383: URL: https://github.com/apache/ignite-3/pull/6383#discussion_r2265807587
########## modules/client/src/main/java/org/apache/ignite/internal/client/sql/ClientSql.java: ########## @@ -287,6 +291,38 @@ public <T> CompletableFuture<AsyncResultSet<T>> executeAsync( @Nullable CancellationToken cancellationToken, Statement statement, @Nullable Object... arguments) { + return executeAsyncInternal( Review Comment: let's add a few test cases to `org.apache.ignite.client.ClientSqlTest` to make sure serialization works as expected ########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java: ########## @@ -54,6 +54,18 @@ public enum SqlQueryType { /** A set of all query types. **/ public static final Set<SqlQueryType> ALL = EnumSet.allOf(SqlQueryType.class); + /** A set of types that {@link #hasRowSet() has row set}. */ + public static final Set<SqlQueryType> HAS_ROW_SET_TYPES = Arrays.stream(values()) + .filter(SqlQueryType::hasRowSet).collect(Collectors.toCollection(() -> EnumSet.noneOf(SqlQueryType.class))); + + /** A set of types that {@link #returnsAffectedRows() returns number of affected rows}. */ Review Comment: ```suggestion /** A set of types that {@link #returnsAffectedRows() returns number of affected rows}. Represented by various DML statements. */ ``` ########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java: ########## @@ -54,6 +54,18 @@ public enum SqlQueryType { /** A set of all query types. **/ public static final Set<SqlQueryType> ALL = EnumSet.allOf(SqlQueryType.class); + /** A set of types that {@link #hasRowSet() has row set}. */ + public static final Set<SqlQueryType> HAS_ROW_SET_TYPES = Arrays.stream(values()) + .filter(SqlQueryType::hasRowSet).collect(Collectors.toCollection(() -> EnumSet.noneOf(SqlQueryType.class))); + + /** A set of types that {@link #returnsAffectedRows() returns number of affected rows}. */ + public static final Set<SqlQueryType> RETURNS_AFFECTED_ROWS_TYPES = Arrays.stream(values()) + .filter(SqlQueryType::returnsAffectedRows).collect(Collectors.toCollection(() -> EnumSet.noneOf(SqlQueryType.class))); + + /** A set of types that {@link #supportsWasApplied() returns boolean indiccating whether command was applied or not}. */ Review Comment: ```suggestion /** A set of types that {@link #supportsWasApplied() returns boolean indicating whether command was applied or not}. Represented by various DDL statements and operational commands. */ ``` ########## modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/sql/ClientSqlCommon.java: ########## @@ -196,4 +201,34 @@ static void packColumns(ClientMessagePacker out, List<ColumnMetadata> cols) { } } } + + static Set<SqlQueryType> unpackAllowedQueryTypes(ClientMessageUnpacker unpacker) { + int size = unpacker.unpackByte(); + Set<SqlQueryType> result = EnumSet.noneOf(SqlQueryType.class); + + for (int i = 0; i < size; i++) { + byte typeId = unpacker.unpackByte(); Review Comment: I would prefer to pack everything as a single byte, not a byte per allowed type ########## modules/client-handler/src/test/java/org/apache/ignite/client/handler/requests/sql/ClientSqlCommonTest.java: ########## @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.client.handler.requests.sql; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.util.Set; +import org.apache.ignite.internal.client.sql.AllowedQueryType; +import org.apache.ignite.internal.sql.engine.SqlQueryType; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +/** + * Tests for {@link ClientSqlCommonTest}. + */ +public class ClientSqlCommonTest { + @ParameterizedTest + @EnumSource(AllowedQueryType.class) + void testConvertAllowedTypeToQueryType(AllowedQueryType type) { + Set<SqlQueryType> sqlQueryTypes = ClientSqlCommon.convertAllowedTypeToQueryType(type); + + assertFalse(sqlQueryTypes.isEmpty()); + + sqlQueryTypes.forEach(sqlQueryType -> { Review Comment: we need to make sure also that none of existing SqlQueryType is missing. Assume we add a new type which for some reason doesn't fall in any of the ALLOW-ed types. We need to highlight such cases ########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/SqlQueryType.java: ########## @@ -54,6 +54,18 @@ public enum SqlQueryType { /** A set of all query types. **/ public static final Set<SqlQueryType> ALL = EnumSet.allOf(SqlQueryType.class); + /** A set of types that {@link #hasRowSet() has row set}. */ Review Comment: ```suggestion /** A set of types that {@link #hasRowSet() has row set}. Usually represented by SELECT statement. */ ``` -- 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