ascherbakoff commented on a change in pull request #326: URL: https://github.com/apache/ignite-3/pull/326#discussion_r705912364
########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/IgniteSql.java ########## @@ -0,0 +1,67 @@ +/* + * 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.query.sql; + +import java.util.UUID; +import org.jetbrains.annotations.NotNull; + +/** + * Ignite SQL query facade. + */ +public interface IgniteSql { + /** + * Creates SQL session. + * + * @return Session. + */ + SqlSession session(); Review comment: ```suggestion SqlSession newSession(); ``` ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/IgniteSql.java ########## @@ -0,0 +1,67 @@ +/* + * 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.query.sql; + +import java.util.UUID; +import org.jetbrains.annotations.NotNull; + +/** + * Ignite SQL query facade. + */ +public interface IgniteSql { Review comment: ```suggestion public interface IgniteSQL { ``` Can we remove all SQL prefixes from API ? They seem redundant. e.g SqlSession -> Session SqlStatement -> Statement or PreparedStatement SqlMultiResultSet -> MultiResultSet etc ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/SqlResultSetMeta.java ########## @@ -0,0 +1,63 @@ +/* + * 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.query.sql; + +import java.util.List; + +/** + * ResultSet metadata. + */ +public interface SqlResultSetMeta { Review comment: ```suggestion public interface ResultSetMetadata { ``` ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/SqlSession.java ########## @@ -0,0 +1,113 @@ +/* + * 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.query.sql; + +import java.util.concurrent.TimeUnit; +import org.apache.ignite.query.sql.async.AsyncSqlSession; +import org.apache.ignite.query.sql.reactive.ReactiveSqlSession; +import org.apache.ignite.tx.Transaction; +import org.jetbrains.annotations.NotNull; + +/** + * SQL Session provides methods for query execution. + */ +public interface SqlSession extends AsyncSqlSession, ReactiveSqlSession { + /** + * Creates transactional SQL session projection with given transaction. + * + * @param tx Transaction. + * @return Transactional projection for the session. + */ + SqlTx withTransaction(@NotNull Transaction tx); + + /** + * Creates transactional SQL session projection with a new transaction. + * + * @return Transactional projection for the session. + */ + SqlTx withNewTransaction(); + + /** + * Sets default query timeout. + * + * @param timeout Query timeout value. + * @param timeUnit Timeunit. + */ + void defaultTimeout(int timeout, TimeUnit timeUnit); + + /** + * Gets default query timeout. + * + * @param timeUnit Timeunit. + * @return Default query timeout. + */ + long defaultTimeout(TimeUnit timeUnit); + + /** + * Sets default query schema. + * + * @param schema Default schema. + */ + void defaultSchema(@NotNull String schema); + + /** + * Gets default query schema. + * + * @return Default query schema. + */ + String defaultSchema(); + + /** + * Executes single SQL query. + * + * @param query SQL query template. + * @param arguments Arguments for the template (optional). + * @return SQL query results set. + * @throws SQLException If failed. + */ + SqlResultSet execute(@NotNull String query, Object... arguments); + + /** + * Executes single SQL statement. + * + * @param statement SQL statement to execute. + * @return SQL query results set. + */ + SqlResultSet execute(@NotNull SqlStatement statement); + + /** + * Executes multi-statement SQL query. + * + * @param query SQL query template. + * @param arguments Arguments for the template (optional). + * @return SQL query results set. + * @throws SQLException If failed. + */ + SqlMultiResultSet executeMulti(@NotNull String query, Object... arguments); Review comment: I'm not sure we need this. Queries can be executed one by one and chained using CompletionStage ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/SqlColumnMeta.java ########## @@ -0,0 +1,55 @@ +/* + * 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.query.sql; + +import org.apache.ignite.schema.ColumnType; + +/** + * Column metadata. + */ +public interface SqlColumnMeta { Review comment: ```suggestion public interface ColumnMetadata { ``` ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/reactive/MultiStatementSubscriber.java ########## @@ -0,0 +1,31 @@ +/* + * 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.query.sql.reactive; + +import java.util.concurrent.Flow; +import org.apache.ignite.query.sql.SqlRow; + +/** + * Dummy subscriber for test purposes. + */ +interface MultiStatementSubscriber<T> extends Flow.Subscriber<T> { Review comment: All reactive stuff looks like a paradigm shift to me, because we currently using CompletableStage based approach for async execution. Not sure if this is needed. ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/SqlRow.java ########## @@ -0,0 +1,30 @@ +/* + * 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.query.sql; + +import org.apache.ignite.table.Tuple; + +/** + * SQL row provides methods to access row data by column name or id. + * + * Column description can be retrived from {@link SqlResultSet#metadata()}. + * @see SqlColumnMeta + */ +public interface SqlRow extends Tuple { Review comment: Why don't use Tuple directly ? ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/async/AsyncSqlResultSet.java ########## @@ -0,0 +1,71 @@ +/* + * 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.query.sql.async; + +import java.util.UUID; +import java.util.concurrent.CompletionStage; +import org.apache.ignite.query.sql.QueryType; +import org.apache.ignite.query.sql.SqlResultSetMeta; +import org.apache.ignite.query.sql.SqlRow; + +/** + * Asynchronous result set. + */ +public interface AsyncSqlResultSet { Review comment: This async cursor API seems more appropriate to me and allow true async processing [1] Paging/batching things on a interface smell and should be removed IMO. [1] https://neo4j.com/docs/api/java-driver/current/org/neo4j/driver/async/ResultCursor.html ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/SqlTx.java ########## @@ -0,0 +1,42 @@ +/* + * 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.query.sql; + +import org.apache.ignite.tx.Transaction; + +/** + * Transactional SQL session projection. + */ +public interface SqlTx extends SqlSession { Review comment: Tx part looks totally wrong to me. This interface is not needed. Instead we should have methods on a Transaction (in addition to table enslisting): /** * Wraps SQL session into a transaction. * @param s The session. * @return The elisted session. */ Session wrap(Session s); /** * Wraps a session into a transaction. * @param t The session. * @return The future for chaining. */ CompletableFuture<Session> wrapAsync(Session s); See ignite-15085 branch for more details. ########## File path: modules/api/src/main/java/org/apache/ignite/query/sql/IgniteSql.java ########## @@ -0,0 +1,67 @@ +/* + * 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.query.sql; + +import java.util.UUID; +import org.jetbrains.annotations.NotNull; + +/** + * Ignite SQL query facade. + */ +public interface IgniteSql { + /** + * Creates SQL session. + * + * @return Session. + */ + SqlSession session(); + + /** + * Creates statement. + * + * @param sql SQL query template. + * @return Prepared statement. + * @throws SQLException If parsing failed. + */ + SqlStatement prepare(@NotNull String sql); + + /** + * Kills query by its' id. + * + * @param queryID Query id. + */ + void killQuery(UUID queryID); + + /** + * Returns statistics facade for table statistics management. + * <p> + * Table statistics are used by SQL engine for SQL queries planning. + * + * @return Statistics facade. + */ + // TODO: Do we need this here or move to Table facade? + IgniteTableStatistics statistics(); Review comment: All table stats stuff should be on a table API. We don't need the separate interface for managing stats. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
