You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2021/08/02 12:06:05 UTC

[ignite-3] 04/05: Minors

This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-15212
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit a707a38482a14f4abb35a7e850d253920642a6ea
Author: Andrew Mashenkov <an...@gmail.com>
AuthorDate: Fri Jul 30 14:18:05 2021 +0300

    Minors
---
 .../org/apache/ignite/query/sql/IgniteSql.java     | 65 +++++++++--------
 .../ignite/query/sql/IgniteTableStatistics.java    | 81 ++++++++++++++++++++++
 .../org/apache/ignite/query/sql/SqlColumnMeta.java |  2 -
 .../org/apache/ignite/query/sql/SqlResultSet.java  |  4 ++
 4 files changed, 117 insertions(+), 35 deletions(-)

diff --git a/modules/api/src/main/java/org/apache/ignite/query/sql/IgniteSql.java b/modules/api/src/main/java/org/apache/ignite/query/sql/IgniteSql.java
index 395100e..e5a1d3a 100644
--- a/modules/api/src/main/java/org/apache/ignite/query/sql/IgniteSql.java
+++ b/modules/api/src/main/java/org/apache/ignite/query/sql/IgniteSql.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.query.sql;
 
-import java.util.Collection;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
 import org.apache.ignite.query.sql.reactive.ReactiveSqlResultSet;
@@ -34,11 +33,11 @@ public interface IgniteSql {
      * Shortcut method for running a query.
      *
      * @param sql SQL query template.
-     * @param args Arguments for template (optional)
+     * @param args Arguments for template (optional).
      * @return SQL query resultset.
      * @throws SQLException If failed.
      */
-    SqlResultSet execute(@NotNull String sql, @Nullable Object... args);
+    SqlResultSet execute(@NotNull String sql, Object... args);
 
     /**
      * Shortcut method for running a query in asynchronously.
@@ -62,16 +61,31 @@ public interface IgniteSql {
      */
     ReactiveSqlResultSet executeReactive(String sql, Object... args);
 
-    //TODO: Do we need a separate methods for DML/DDL that do not return the resultset? or extend a resultset?
+    /**
+     * Shortcut method for running a non-query statement.
+     *
+     * @param sql SQL statement template.
+     * @param args Agruments for template (optional).
+     * @return Number of updated rows.
+     */
+    int executeNonQuery(@NotNull String sql, @Nullable Object... args);
+    //TODO: useful for bulk DML query, when we don't care of results.
+    //TODO: in contrary, execute() method may return inserted rows IDs that looks useful if AutoIncrement ID column is used.
+
     //TODO: same methods for Statement.
 
-    ///////////////// Query monitoring and management.
     /**
-     * Return info of the queries. //TODO: "running on the node locally"? or "started on the node"? or both?
+     * Sets query session parameter.
      *
-     * @return Running queries infos.
+     * @param name Parameter name.
+     * @param value Parameter value.
      */
-    Collection<Object> runningQueries(); //TODO: Is it needed here or to be moved into the Views facade?
+    void setParameter(String name, Object value);
+    //TODO: User can set e.g. queryTimeout or force join order or whatever.
+    //TODO: This is similar to SQL "SET" operator which is used in JDBC/ODBC clients for session state manipulation.
+
+
+    //TODO: Move all of this to Session. Maybe facade instance could incapsulate a session implicitely?
 
     /**
      * Kills query by its' id.
@@ -81,34 +95,19 @@ public interface IgniteSql {
     void killQuery(UUID queryID);
 
     /**
-     * Returns SQL views.
+     * Returns statistics facade for table statistics management.
+     *
+     * Table statistics are used by SQL engine for SQL queries planning.
+     *
+     * @return Statistics facade.
      */
-    Object views(); //TODO: TBD.
-
-    //TODO: View for running queries?
-    //TODO: View for memory Management?
-    //TODO: View for QueryMetrics?
-    //TODO: Any other SystemViews from Igntie 2.0?
-
-    ////////////// Statistics management.
-    Collection<Object> tableStatistics(String table); //TODO: Local or global? Ready or in-progress? TBD.
-
-    CompletableFuture<Void> gatherStatistics(String table, Object statisticsConfiguration);
-    //TODO: Creates new statistics in addition, or drop old and replaces with new?
-    //TODO: Should the existed one be refreshed?
-
-    CompletableFuture<Void> refreshStatistics(String table, @Nullable String... optionalStatisticName);
-
-    void dropStatistics(String table, @Nullable String... optionalStatisticName);
-
-    void refreshLocalStatistics(String table, @Nullable String... optionalStatisticName); //TODO: Actually, drops local statistics to be automatically refreshed.
-
-
-    //////////////////// DDL
+    IgniteTableStatistics statistics();
+    // TODO: Do we need this here or move to Table facade?
 
-    //TODO: Do we expect any SQL DDL pragrammatical API here? Why we have tables().create(), but not here?
-    //TODO: alterTable()?
 
+    void registerUserFunction(Class type, String... methodNames); //TODO: Get function details from method annotations.
+    void registerUserFunction(Class type);
+    void unregistedUserFunction(String functionName);
     //TODO: Custom function registration. Do we need a view and unregister functionality?
 }
 
diff --git a/modules/api/src/main/java/org/apache/ignite/query/sql/IgniteTableStatistics.java b/modules/api/src/main/java/org/apache/ignite/query/sql/IgniteTableStatistics.java
new file mode 100644
index 0000000..d523b7f
--- /dev/null
+++ b/modules/api/src/main/java/org/apache/ignite/query/sql/IgniteTableStatistics.java
@@ -0,0 +1,81 @@
+/*
+ * 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.Collection;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Table statistics facade provides methods for managing table statistics.
+ * <p>
+ * Table statistics are used by SQL engine for SQL queries planning.
+ */
+public interface IgniteTableStatistics {
+    /**
+     * Get statistics info for table.
+     *
+     * @param tableName Table name.
+     * @return Statistics info collection.
+     */
+    Collection<StatisticInfo> statistics(String tableName); //TODO: Local or global? Ready or in-progress? TBD.
+
+    /**
+     * Creates statistics for a table and initiate it gathering on the nodes.
+     *
+     * @param tableName Table name.
+     * @param statisticsConfiguration Statistic configuration.
+     * @return Operation future.
+     */
+    CompletableFuture<Void> gather(String tableName, Object statisticsConfiguration);
+    //TODO: Creates new statistics in addition, or drop old and replaces with new?
+    //TODO: Should the existed one be refreshed? or fail with exception?
+    //TODO: What if existed statistics has different configuration?
+    //TODO: Can future be cancelled?
+
+    /**
+     * Refresh a global statistic by given name or all existed statistics if no statistic name specified.
+     *
+     * @param tableName Table name.
+     * @param statisticNames Statistic names (optional).
+     * @return Operation future.
+     */
+    CompletableFuture<Void> refresh(String tableName, String... statisticNames);
+    //TODO: What if statistics with name is not exists? one of names?
+
+    /**
+     * Drop table statistic.
+     *
+     * @param tableName Table name.
+     * @param statisticNames Statistic names.     //TODO: Can be empty?
+     */
+    void drop(String tableName, String... statisticNames);
+
+    /**
+     * Refresh local statistic.
+     *
+     * @param tableName Table name.
+     * @param statisticNames Statistic names.
+     */
+    void refreshLocal(String tableName, String... statisticNames); //TODO: Actually, drops local statistics to be automatically refreshed.
+
+    //TODO TBD.
+    interface StatisticInfo {
+        String name();
+        Object config();
+    }
+}
diff --git a/modules/api/src/main/java/org/apache/ignite/query/sql/SqlColumnMeta.java b/modules/api/src/main/java/org/apache/ignite/query/sql/SqlColumnMeta.java
index 856c82f..c7250a4 100644
--- a/modules/api/src/main/java/org/apache/ignite/query/sql/SqlColumnMeta.java
+++ b/modules/api/src/main/java/org/apache/ignite/query/sql/SqlColumnMeta.java
@@ -48,7 +48,6 @@ public interface SqlColumnMeta {
      * @return Value type.
      */
     Class<?> valueClass();
-    //TODO: this maybe more useful in contraty to the previous one.
 
     /**
      * Row column nullability.
@@ -56,5 +55,4 @@ public interface SqlColumnMeta {
      * @return {@code true} if column is nullable, {@code false} otherwise.
      */
     boolean nullable();
-    //TODO: AFAIK, Calcite can derive column type for us.
 }
diff --git a/modules/api/src/main/java/org/apache/ignite/query/sql/SqlResultSet.java b/modules/api/src/main/java/org/apache/ignite/query/sql/SqlResultSet.java
index 174c914..2bbadcf 100644
--- a/modules/api/src/main/java/org/apache/ignite/query/sql/SqlResultSet.java
+++ b/modules/api/src/main/java/org/apache/ignite/query/sql/SqlResultSet.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.query.sql;
 
+import java.util.UUID;
+
 /**
  * SQL result set provides methods to access SQL query resul represented as collection of {@link SqlRow}.
  *
@@ -30,4 +32,6 @@ public interface SqlResultSet extends Iterable<SqlRow>, AutoCloseable {
      * @return ResultSet metadata.
      */
     SqlResultSetMeta metadata();
+
+    UUID queryId();
 }