This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 49babe37173 branch-3.1: [feature](information_schema) add rowsets
table into information_schema in cloud mode #42367 (#52330)
49babe37173 is described below
commit 49babe37173ffca5f920dd0461b09eb7166209c1
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Jun 26 18:17:34 2025 +0800
branch-3.1: [feature](information_schema) add rowsets table into
information_schema in cloud mode #42367 (#52330)
Cherry-picked from #42367
Co-authored-by: Uniqueyou <[email protected]>
---
.../exec/schema_scanner/schema_rowsets_scanner.cpp | 18 +++++-
.../system/test_query_sys_scan_rowsets.out | Bin 0 -> 679 bytes
.../system/test_query_sys_scan_rowsets.groovy | 71 +++++++++++++++++++++
3 files changed, 88 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 16d5f2daba6..3aa0e944a82 100644
--- a/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp
+++ b/be/src/exec/schema_scanner/schema_rowsets_scanner.cpp
@@ -26,6 +26,9 @@
#include <string>
#include <utility>
+#include "cloud/cloud_storage_engine.h"
+#include "cloud/cloud_tablet.h"
+#include "cloud/cloud_tablet_mgr.h"
#include "cloud/config.h"
#include "common/status.h"
#include "olap/olap_common.h"
@@ -35,6 +38,7 @@
#include "olap/tablet.h"
#include "olap/tablet_manager.h"
#include "runtime/define_primitive_type.h"
+#include "runtime/exec_env.h"
#include "runtime/runtime_state.h"
#include "util/runtime_profile.h"
#include "vec/common/string_ref.h"
@@ -78,7 +82,19 @@ Status SchemaRowsetsScanner::start(RuntimeState* state) {
Status SchemaRowsetsScanner::_get_all_rowsets() {
if (config::is_cloud_mode()) {
- return Status::NotSupported("SchemaRowsetsScanner::_get_all_rowsets is
not implemented");
+ // only query cloud tablets in lru cache instead of all tablets
+ std::vector<std::weak_ptr<CloudTablet>> tablets =
+
ExecEnv::GetInstance()->storage_engine().to_cloud().tablet_mgr().get_weak_tablets();
+ for (const std::weak_ptr<CloudTablet>& tablet : tablets) {
+ if (!tablet.expired()) {
+ auto t = tablet.lock();
+ std::shared_lock rowset_ldlock(t->get_header_lock());
+ for (const auto& it : t->rowset_map()) {
+ rowsets_.emplace_back(it.second);
+ }
+ }
+ }
+ return Status::OK();
}
std::vector<TabletSharedPtr> tablets =
ExecEnv::GetInstance()->storage_engine().to_local().tablet_manager()->get_all_tablet();
diff --git
a/regression-test/data/query_p0/system/test_query_sys_scan_rowsets.out
b/regression-test/data/query_p0/system/test_query_sys_scan_rowsets.out
new file mode 100644
index 00000000000..b034ebe1bbd
Binary files /dev/null and
b/regression-test/data/query_p0/system/test_query_sys_scan_rowsets.out differ
diff --git
a/regression-test/suites/query_p0/system/test_query_sys_scan_rowsets.groovy
b/regression-test/suites/query_p0/system/test_query_sys_scan_rowsets.groovy
new file mode 100644
index 00000000000..48281198cfd
--- /dev/null
+++ b/regression-test/suites/query_p0/system/test_query_sys_scan_rowsets.groovy
@@ -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.
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+suite("test_query_sys_scan_rowsets", "query,p0") {
+ def dbName1 = "test_query_sys_scan_rowsets"
+
+ if (!isCloudMode()) {
+ log.info("not cloud mode")
+ return
+ }
+
+
+ sql("CREATE DATABASE IF NOT EXISTS ${dbName1}")
+
+ // test rowsets
+ qt_desc_rowsets """ desc information_schema.rowsets """
+ def rowsets_table_name = """ test_query_sys_scan_rowsets.test_query_rowset
"""
+ sql """ drop table if exists ${rowsets_table_name} """
+
+ sql """
+ create table ${rowsets_table_name}(
+ a int ,
+ b boolean ,
+ c string )
+ DISTRIBUTED BY HASH(`a`) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1",
+ "disable_auto_compaction" = "true",
+ "enable_single_replica_compaction"="true"
+ );
+ """
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
+ def now = sdf.format(new Date()).toString();
+
+ def rowsets_table_name_tablets = sql_return_maparray """ show tablets from
${rowsets_table_name}; """
+ def tablet_id = rowsets_table_name_tablets[0].TabletId
+
+ sql """ select * from ${rowsets_table_name}; """
+ order_qt_rowsets1 """ select START_VERSION,END_VERSION from
information_schema.rowsets where TABLET_ID=${tablet_id} group by
START_VERSION,END_VERSION order by START_VERSION,END_VERSION; """
+
+ sql """ insert into ${rowsets_table_name} values (1,0,"abc"); """
+ sql """ select * from ${rowsets_table_name}; """
+ order_qt_rowsets2 """ select START_VERSION,END_VERSION from
information_schema.rowsets where TABLET_ID=${tablet_id} group by
START_VERSION,END_VERSION order by START_VERSION,END_VERSION; """
+
+ sql """ insert into ${rowsets_table_name} values (2,1,"hello world");
"""
+ sql """ insert into ${rowsets_table_name} values (3,0,"dssadasdsafafdf");
"""
+ sql """ select * from ${rowsets_table_name}; """
+ order_qt_rowsets3 """ select START_VERSION,END_VERSION from
information_schema.rowsets where TABLET_ID=${tablet_id} group by
START_VERSION,END_VERSION order by START_VERSION,END_VERSION; """
+
+ sql """ insert into ${rowsets_table_name} values (4,0,"abcd"); """
+ sql """ select * from ${rowsets_table_name}; """
+ order_qt_rowsets4 """ select START_VERSION,END_VERSION from
information_schema.rowsets where TABLET_ID=${tablet_id} and
NEWEST_WRITE_TIMESTAMP>='${now}' group by START_VERSION,END_VERSION order by
START_VERSION,END_VERSION; """
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]