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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 77b9acc  [Stmt] Add rowCount column to SHOW DATA stmt (#3676)
77b9acc is described below

commit 77b9acc2428e523c0c593ca6605c782b3250c273
Author: Mingyu Chen <[email protected]>
AuthorDate: Tue May 26 15:53:38 2020 +0800

    [Stmt] Add rowCount column to SHOW DATA stmt (#3676)
    
    User can see the row count of all materialized indexes of a table.
    
    ```
    mysql> show data from test;
    +-----------+-----------+-----------+--------------+----------+
    | TableName | IndexName | Size      | ReplicaCount | RowCount |
    +-----------+-----------+-----------+--------------+----------+
    | test2     | r1        | 10.000MB  | 30           | 10000    |
    |           | r2        | 20.000MB  | 30           | 20000    |
    |           | test2     | 50.000MB  | 30           | 50000    |
    |           | Total     | 80.000    | 90           |          |
    +-----------+-----------+-----------+--------------+----------+
    ```
    
    Fix #3675
---
 .../sql-statements/Data Manipulation/SHOW DATA.md  | 60 +++++++++++++++----
 .../sql-statements/Data Manipulation/SHOW DATA.md  | 68 +++++++++++++++++-----
 .../org/apache/doris/analysis/ShowDataStmt.java    | 11 +++-
 .../apache/doris/analysis/ShowDataStmtTest.java    |  4 +-
 4 files changed, 115 insertions(+), 28 deletions(-)

diff --git a/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW 
DATA.md b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW DATA.md
index c29bac4..6240782 100644
--- a/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW DATA.md       
+++ b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW DATA.md       
@@ -25,22 +25,62 @@ under the License.
 -->
 
 # SHOW DATA
+
 ## Description
-This statement is used to show the amount of data and the number of replica
-Grammar:
+
+This statement is used to show the amount of data, the number of replica and 
num of rows.
+
+Syntax:
+
+```
 SHOW DATA [FROM db_name[.table_name]];
+```
 
 Explain:
-1. If you do not specify the FROM clause, use the amount of data and the 
number of replica that shows the current DB subdivided into tables
-2. If the FROM clause is specified, the amount of data and the number of 
replica subdivided into indices under the table is shown.
-3. If you want to see the size of individual Partitions, see help show 
partitions
+
+1. If the FROM clause is not specified, the amount of data and the number of 
copies subdivided into each table under the current db are displayed. The data 
volume is the total data volume of all replicas. The number of replicas is of 
all partitions of the table and all materialized views.
+
+2. If the FROM clause is specified, the amount of data, the number of 
replicas, and the number of statistical rows subdivided into individual 
materialized views under table are displayed. The data volume is the total data 
volume of all replicas. The number of replicas is corresponding to all 
partitions of the materialized view. The number of statistical rows is 
corresponding to all partitions of the materialized view.
+
+3. When counting the number of rows, the replica with the largest number of 
rows among multiple replicas shall prevail.
+
+4. The `Total` row in the result set represents the summary row. The `Quota` 
row indicates the current quota of the database. The `Left` line indicates the 
remaining quota.
 
 ## example
-1. Display the data volume, replica size, aggregate data volume and aggregate 
replica count of each table of default DB
-SHOW DATA;
 
-2. Display the subdivision data volume and replica count of the specified 
table below the specified DB
-SHOW DATA FROM example_db.table_name;
+1. Display the data volume, replica size, aggregate data volume and aggregate 
replica count of each table of default DB.
+
+    ```
+    SHOW DATA;
+    ```
+    
+    ```
+    +-----------+-------------+--------------+
+    | TableName | Size        | ReplicaCount |
+    +-----------+-------------+--------------+
+    | tbl1      | 900.000 B   | 6            |
+    | tbl2      | 500.000 B   | 3            |
+    | Total     | 1.400 KB    | 9            |
+    | Quota     | 1024.000 GB | 1073741824   |
+    | Left      | 1021.921 GB | 1073741815   |
+    +-----------+-------------+--------------+
+    ```
+
+2. Display the subdivision data volume, replica count and number of rows of 
the specified table below the specified DB.
+
+    ```
+    SHOW DATA FROM example_db.test;
+    
+    +-----------+-----------+-----------+--------------+----------+
+    | TableName | IndexName | Size      | ReplicaCount | RowCount |
+    +-----------+-----------+-----------+--------------+----------+
+    | test      | r1        | 10.000MB  | 30           | 10000    |
+    |           | r2        | 20.000MB  | 30           | 20000    |
+    |           | test2     | 50.000MB  | 30           | 50000    |
+    |           | Total     | 80.000    | 90           |          |
+    +-----------+-----------+-----------+--------------+----------+
+    ```
 
 ## keyword
-SHOW,DATA
+
+    SHOW,DATA
diff --git a/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW 
DATA.md b/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW DATA.md
index 494f980..8361033 100644
--- a/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW DATA.md    
+++ b/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW DATA.md    
@@ -25,23 +25,65 @@ under the License.
 -->
 
 # SHOW DATA
+
 ## description
-    该语句用于展示数据量和副本数量
-    语法:
-        SHOW DATA [FROM db_name[.table_name]];
-        
-    说明:
-        1. 如果不指定 FROM 子句,使用展示当前 db 下细分到各个 table 的数据量和副本数量
-        2. 如果指定 FROM 子句,则展示 table 下细分到各个 index 的数据量和副本数量
-        3. 如果想查看各个 Partition 的大小,请参阅 help show partitions
+
+该语句用于展示数据量、副本数量以及统计行数。
+
+语法:
+
+```
+SHOW DATA [FROM db_name[.table_name]];
+```
+    
+说明:
+
+1. 如果不指定 FROM 子句,则展示当前 db 下细分到各个 table 
的数据量和副本数量。其中数据量为所有副本的总数据量。而副本数量为表的所有分区以及所有物化视图的副本数量。
+
+2. 如果指定 FROM 子句,则展示 table 
下细分到各个物化视图的数据量、副本数量和统计行数。其中数据量为所有副本的总数据量。副本数量为对应物化视图的所有分区的副本数量。统计行数为对应物化视图的所有分区统计行数。
+
+3. 统计行数时,以多个副本中,行数最大的那个副本为准。
+
+4. 结果集中的 `Total` 行表示汇总行。`Quota` 行表示当前数据库设置的配额。`Left` 行表示剩余配额。
+
+5. 如果想查看各个 Partition 的大小,请参阅 `help show partitions`。
 
 ## example
-    1. 展示默认 db 的各个 table 的数据量,副本数量,汇总数据量和汇总副本数量。
-        SHOW DATA;
-        
-    2. 展示指定 db 的下指定表的细分数据量和副本数量
-        SHOW DATA FROM example_db.table_name;
+
+1. 展示默认 db 的各个 table 的数据量,副本数量,汇总数据量和汇总副本数量。
+    
+    ```
+    SHOW DATA;
+    ```
+    
+    ```
+    +-----------+-------------+--------------+
+    | TableName | Size        | ReplicaCount |
+    +-----------+-------------+--------------+
+    | tbl1      | 900.000 B   | 6            |
+    | tbl2      | 500.000 B   | 3            |
+    | Total     | 1.400 KB    | 9            |
+    | Quota     | 1024.000 GB | 1073741824   |
+    | Left      | 1021.921 GB | 1073741815   |
+    +-----------+-------------+--------------+
+    ```
+    
+2. 展示指定 db 的下指定表的细分数据量、副本数量和统计行数
+
+    ```
+    SHOW DATA FROM example_db.test;
+    
+    +-----------+-----------+-----------+--------------+----------+
+    | TableName | IndexName | Size      | ReplicaCount | RowCount |
+    +-----------+-----------+-----------+--------------+----------+
+    | test      | r1        | 10.000MB  | 30           | 10000    |
+    |           | r2        | 20.000MB  | 30           | 20000    |
+    |           | test2     | 50.000MB  | 30           | 50000    |
+    |           | Total     | 80.000    | 90           |          |
+    +-----------+-----------+-----------+--------------+----------+
+    ```
 
 ## keyword
+
     SHOW,DATA
 
diff --git a/fe/src/main/java/org/apache/doris/analysis/ShowDataStmt.java 
b/fe/src/main/java/org/apache/doris/analysis/ShowDataStmt.java
index dc85665..8a1eee6 100644
--- a/fe/src/main/java/org/apache/doris/analysis/ShowDataStmt.java
+++ b/fe/src/main/java/org/apache/doris/analysis/ShowDataStmt.java
@@ -62,6 +62,7 @@ public class ShowDataStmt extends ShowStmt {
                     .addColumn(new Column("IndexName", 
ScalarType.createVarchar(20)))
                     .addColumn(new Column("Size", 
ScalarType.createVarchar(30)))
                     .addColumn(new Column("ReplicaCount", 
ScalarType.createVarchar(20)))
+                    .addColumn(new Column("RowCount", 
ScalarType.createVarchar(20)))
                     .build();
 
     private String dbName;
@@ -194,10 +195,12 @@ public class ShowDataStmt extends ShowStmt {
                 for (Long indexId : sortedIndexNames.values()) {
                     long indexSize = 0;
                     long indexReplicaCount = 0;
+                    long indexRowCount = 0;
                     for (Partition partition : olapTable.getAllPartitions()) {
                         MaterializedIndex mIndex = partition.getIndex(indexId);
                         indexSize += mIndex.getDataSize();
                         indexReplicaCount += mIndex.getReplicaCount();
+                        indexRowCount += mIndex.getRowCount();
                     }
 
                     Pair<Double, String> indexSizePair = 
DebugUtil.getByteUint(indexSize);
@@ -208,11 +211,13 @@ public class ShowDataStmt extends ShowStmt {
                     if (i == 0) {
                         row = Arrays.asList(tableName,
                                             
olapTable.getIndexNameById(indexId),
-                                            readableSize, 
String.valueOf(indexReplicaCount));
+                                            readableSize, 
String.valueOf(indexReplicaCount),
+                                            String.valueOf(indexRowCount));
                     } else {
                         row = Arrays.asList("",
                                             
olapTable.getIndexNameById(indexId),
-                                            readableSize, 
String.valueOf(indexReplicaCount));
+                                            readableSize, 
String.valueOf(indexReplicaCount),
+                                            String.valueOf(indexRowCount));
                     }
 
                     totalSize += indexSize;
@@ -225,7 +230,7 @@ public class ShowDataStmt extends ShowStmt {
                 Pair<Double, String> totalSizePair = 
DebugUtil.getByteUint(totalSize);
                 String readableSize = 
DebugUtil.DECIMAL_FORMAT_SCALE_3.format(totalSizePair.first) + " "
                         + totalSizePair.second;
-                List<String> row = Arrays.asList("", "Total", readableSize, 
String.valueOf(totalReplicaCount));
+                List<String> row = Arrays.asList("", "Total", readableSize, 
String.valueOf(totalReplicaCount), "");
                 totalRows.add(row);
             }
         } finally {
diff --git a/fe/src/test/java/org/apache/doris/analysis/ShowDataStmtTest.java 
b/fe/src/test/java/org/apache/doris/analysis/ShowDataStmtTest.java
index edcff94..d892bbd 100644
--- a/fe/src/test/java/org/apache/doris/analysis/ShowDataStmtTest.java
+++ b/fe/src/test/java/org/apache/doris/analysis/ShowDataStmtTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.doris.analysis;
 
-import mockit.Expectations;
 import org.apache.doris.backup.CatalogMocker;
 import org.apache.doris.catalog.Catalog;
 import org.apache.doris.catalog.Database;
@@ -33,6 +32,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import mockit.Expectations;
 import mockit.Mocked;
 
 public class ShowDataStmtTest {
@@ -141,7 +141,7 @@ public class ShowDataStmtTest {
         stmt = new ShowDataStmt("testDb", "test_tbl");
         stmt.analyze(analyzer);
         Assert.assertEquals("SHOW DATA FROM 
`default_cluster:testDb`.`test_tbl`", stmt.toString());
-        Assert.assertEquals(4, stmt.getMetaData().getColumnCount());
+        Assert.assertEquals(5, stmt.getMetaData().getColumnCount());
         Assert.assertEquals(true, stmt.hasTable());
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to