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

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


The following commit(s) were added to refs/heads/master by this push:
     new ae18a7f0dfd [Feature](information-schema) add SCHEMA_VERSION into 
information_schema.rowsets (#35861)
ae18a7f0dfd is described below

commit ae18a7f0dfd833cd1ab52276a175ed192890e568
Author: Pxl <pxl...@qq.com>
AuthorDate: Thu Jun 6 11:02:10 2024 +0800

    [Feature](information-schema) add SCHEMA_VERSION into 
information_schema.rowsets (#35861)
    
    ## Proposed changes
    add SCHEMA_VERSION into information_schema.rowsets
    ```sql
    mysql [test]>select * from information_schema.rowsets where tablet_id=55182;
    
+------------+--------------------------------------------------+-----------+-----------------+--------+--------------+---------------+-------------+-----------------+----------------+---------------------+------------------------+----------------+
    | BACKEND_ID | ROWSET_ID                                        | TABLET_ID 
| ROWSET_NUM_ROWS | TXN_ID | NUM_SEGMENTS | START_VERSION | END_VERSION | 
INDEX_DISK_SIZE | DATA_DISK_SIZE | CREATION_TIME       | NEWEST_WRITE_TIMESTAMP 
| SCHEMA_VERSION |
    
+------------+--------------------------------------------------+-----------+-----------------+--------+--------------+---------------+-------------+-----------------+----------------+---------------------+------------------------+----------------+
    |      10009 | 020000000000005a714d2f4bc0290907ca9dc2c861aea6bb |     55182 
|               0 |   8013 |            0 |             6 |           6 |       
        0 |              0 | 2024-06-04 16:43:36 | 2024-06-04 16:43:35    |     
         1 |
    |      10009 | 0200000000000040714d2f4bc0290907ca9dc2c861aea6bb |     55182 
|               0 |      0 |            0 |             5 |           5 |       
        0 |              0 | 2024-06-04 16:43:06 | 2024-06-03 15:23:56    |     
         0 |
    |      10009 | 020000000000003e714d2f4bc0290907ca9dc2c861aea6bb |     55182 
|               0 |      0 |            0 |             3 |           3 |       
        0 |              0 | 2024-06-04 16:43:06 | 2024-06-03 15:23:35    |     
         0 |
    |      10009 | 020000000000003c714d2f4bc0290907ca9dc2c861aea6bb |     55182 
|               0 |      0 |            0 |             2 |           2 |       
        0 |              0 | 2024-06-04 16:43:06 | 2024-06-03 15:23:04    |     
         0 |
    |      10009 | 020000000000003f714d2f4bc0290907ca9dc2c861aea6bb |     55182 
|               0 |      0 |            0 |             4 |           4 |       
        0 |              0 | 2024-06-04 16:43:06 | 2024-06-03 15:23:50    |     
         0 |
    |      10009 | 020000000000003a714d2f4bc0290907ca9dc2c861aea6bb |     55182 
|               0 |      0 |            0 |             0 |           1 |       
        0 |              0 | 2024-06-04 16:43:06 | 2024-06-03 15:22:36    |     
         0 |
    
+------------+--------------------------------------------------+-----------+-----------------+--------+--------------+---------------+-------------+-----------------+----------------+---------------------+------------------------+----------------+
    ```
---
 be/src/exec/schema_scanner/schema_rowsets_scanner.cpp       | 13 ++++++++++++-
 .../src/main/java/org/apache/doris/catalog/SchemaTable.java |  1 +
 .../data/query_p0/system/test_query_sys_rowsets.out         |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp 
b/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp
index f66363fde1e..6ece8e22331 100644
--- a/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp
+++ b/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp
@@ -58,6 +58,7 @@ std::vector<SchemaScanner::ColumnDesc> 
SchemaRowsetsScanner::_s_tbls_columns = {
         {"DATA_DISK_SIZE", TYPE_BIGINT, sizeof(size_t), true},
         {"CREATION_TIME", TYPE_DATETIME, sizeof(int64_t), true},
         {"NEWEST_WRITE_TIMESTAMP", TYPE_DATETIME, sizeof(int64_t), true},
+        {"SCHEMA_VERSION", TYPE_INT, sizeof(int32_t), true},
 
 };
 
@@ -114,7 +115,7 @@ Status 
SchemaRowsetsScanner::get_next_block(vectorized::Block* block, bool* eos)
 
 Status SchemaRowsetsScanner::_fill_block_impl(vectorized::Block* block) {
     SCOPED_TIMER(_fill_block_timer);
-    size_t fill_rowsets_num = std::min(1000ul, rowsets_.size() - _rowsets_idx);
+    size_t fill_rowsets_num = std::min(1000UL, rowsets_.size() - _rowsets_idx);
     auto fill_idx_begin = _rowsets_idx;
     auto fill_idx_end = _rowsets_idx + fill_rowsets_num;
     std::vector<void*> datas(fill_rowsets_num);
@@ -242,6 +243,16 @@ Status 
SchemaRowsetsScanner::_fill_block_impl(vectorized::Block* block) {
         }
         RETURN_IF_ERROR(fill_dest_column_for_range(block, 11, datas));
     }
+    // SCHEMA_VERSION
+    {
+        std::vector<int32_t> srcs(fill_rowsets_num);
+        for (int i = fill_idx_begin; i < fill_idx_end; ++i) {
+            RowsetSharedPtr rowset = rowsets_[i];
+            srcs[i - fill_idx_begin] = 
rowset->tablet_schema()->schema_version();
+            datas[i - fill_idx_begin] = srcs.data() + i - fill_idx_begin;
+        }
+        RETURN_IF_ERROR(fill_dest_column_for_range(block, 12, datas));
+    }
 
     _rowsets_idx += fill_rowsets_num;
     return Status::OK();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
index 3d57f922683..6484d12eb15 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
@@ -397,6 +397,7 @@ public class SchemaTable extends Table {
                             .column("DATA_DISK_SIZE", 
ScalarType.createType(PrimitiveType.BIGINT))
                             .column("CREATION_TIME", 
ScalarType.createType(PrimitiveType.DATETIME))
                             .column("NEWEST_WRITE_TIMESTAMP", 
ScalarType.createType(PrimitiveType.DATETIME))
+                            .column("SCHEMA_VERSION", 
ScalarType.createType(PrimitiveType.INT))
                             .build()))
             .put("parameters", new SchemaTable(SystemIdGenerator.getNextId(), 
"parameters", TableType.SCHEMA,
                     builder().column("SPECIFIC_CATALOG", 
ScalarType.createVarchar(64))
diff --git a/regression-test/data/query_p0/system/test_query_sys_rowsets.out 
b/regression-test/data/query_p0/system/test_query_sys_rowsets.out
index 8c9bb68893d..2f91c9028dc 100644
--- a/regression-test/data/query_p0/system/test_query_sys_rowsets.out
+++ b/regression-test/data/query_p0/system/test_query_sys_rowsets.out
@@ -12,6 +12,7 @@ INDEX_DISK_SIZE       BIGINT  Yes     false   \N
 DATA_DISK_SIZE BIGINT  Yes     false   \N      
 CREATION_TIME  DATETIME        Yes     false   \N      
 NEWEST_WRITE_TIMESTAMP DATETIME        Yes     false   \N      
+SCHEMA_VERSION INT     Yes     false   \N      
 
 -- !rowsets1 --
 0      1


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to