This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 131238ff71a [fix](file-cache) change metric_value column in
file_cache_statistics table to string (#40083)
131238ff71a is described below
commit 131238ff71ad48b310c0ba97a8a8b4ece4a3bf46
Author: Mingyu Chen <[email protected]>
AuthorDate: Thu Aug 29 16:39:22 2024 +0800
[fix](file-cache) change metric_value column in file_cache_statistics table
to string (#40083)
Make it more flexible
followup #39552
---
.../schema_file_cache_statistics.cpp | 2 +-
be/src/io/cache/block/block_file_cache_factory.cpp | 16 ++++-----------
.../java/org/apache/doris/catalog/SchemaTable.java | 2 +-
.../system/test_file_cache_statistics.groovy | 24 ++++++++++++++++++++++
4 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/be/src/exec/schema_scanner/schema_file_cache_statistics.cpp
b/be/src/exec/schema_scanner/schema_file_cache_statistics.cpp
index f47961002de..d1ae0bd9a29 100644
--- a/be/src/exec/schema_scanner/schema_file_cache_statistics.cpp
+++ b/be/src/exec/schema_scanner/schema_file_cache_statistics.cpp
@@ -32,7 +32,7 @@ std::vector<SchemaScanner::ColumnDesc>
SchemaFileCacheStatisticsScanner::_s_tbls
{"BE_IP", TYPE_VARCHAR, sizeof(StringRef), false},
{"CACHE_PATH", TYPE_VARCHAR, sizeof(StringRef), false},
{"METRIC_NAME", TYPE_VARCHAR, sizeof(StringRef), false},
- {"METRIC_VALUE", TYPE_DOUBLE, sizeof(double), false}};
+ {"METRIC_VALUE", TYPE_STRING, sizeof(StringRef), false}};
SchemaFileCacheStatisticsScanner::SchemaFileCacheStatisticsScanner()
: SchemaScanner(_s_tbls_columns,
TSchemaTableType::SCH_FILE_CACHE_STATISTICS) {}
diff --git a/be/src/io/cache/block/block_file_cache_factory.cpp
b/be/src/io/cache/block/block_file_cache_factory.cpp
index 017e733c5e0..abe6a38c198 100644
--- a/be/src/io/cache/block/block_file_cache_factory.cpp
+++ b/be/src/io/cache/block/block_file_cache_factory.cpp
@@ -115,6 +115,9 @@ std::vector<IFileCache::QueryFileCacheContextHolderPtr>
FileCacheFactory::get_qu
}
void FileCacheFactory::get_cache_stats_block(vectorized::Block* block) {
+ if (!config::enable_file_cache) {
+ return;
+ }
// std::shared_lock<std::shared_mutex> read_lock(_qs_ctx_map_lock);
TBackend be = BackendOptions::get_local_backend();
int64_t be_id = be.id;
@@ -131,17 +134,6 @@ void
FileCacheFactory::get_cache_stats_block(vectorized::Block* block) {
nullable_column->get_null_map_data().emplace_back(0);
};
- auto insert_double_value = [&](int col_index, double double_val,
vectorized::Block* block) {
- vectorized::MutableColumnPtr mutable_col_ptr;
- mutable_col_ptr =
std::move(*block->get_by_position(col_index).column).assume_mutable();
- auto* nullable_column =
-
reinterpret_cast<vectorized::ColumnNullable*>(mutable_col_ptr.get());
- vectorized::IColumn* col_ptr = &nullable_column->get_nested_column();
-
reinterpret_cast<vectorized::ColumnVector<vectorized::Float64>*>(col_ptr)->insert_value(
- double_val);
- nullable_column->get_null_map_data().emplace_back(0);
- };
-
auto insert_string_value = [&](int col_index, std::string str_val,
vectorized::Block* block) {
vectorized::MutableColumnPtr mutable_col_ptr;
mutable_col_ptr =
std::move(*block->get_by_position(col_index).column).assume_mutable();
@@ -160,7 +152,7 @@ void
FileCacheFactory::get_cache_stats_block(vectorized::Block* block) {
insert_string_value(1, be_ip, block); // be ip
insert_string_value(2, cache->get_base_path(), block); // cache
path
insert_string_value(3, k, block); // metric
name
- insert_double_value(4, v, block); // metric
value
+ insert_string_value(4, std::to_string(v), block); // metric
value
}
}
}
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 b106ab9d796..8fb071feb96 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
@@ -524,7 +524,7 @@ public class SchemaTable extends Table {
.column("BE_IP",
ScalarType.createVarchar(256))
.column("CACHE_PATH",
ScalarType.createVarchar(256))
.column("METRIC_NAME",
ScalarType.createVarchar(256))
- .column("METRIC_VALUE",
ScalarType.createType(PrimitiveType.DOUBLE))
+ .column("METRIC_VALUE",
ScalarType.createStringType())
.build()))
.put("workload_group_privileges",
new SchemaTable(SystemIdGenerator.getNextId(),
"workload_group_privileges", TableType.SCHEMA,
diff --git
a/regression-test/suites/query_p0/system/test_file_cache_statistics.groovy
b/regression-test/suites/query_p0/system/test_file_cache_statistics.groovy
new file mode 100644
index 00000000000..682ba3d4d01
--- /dev/null
+++ b/regression-test/suites/query_p0/system/test_file_cache_statistics.groovy
@@ -0,0 +1,24 @@
+// 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.
+
+suite("test_file_cache_statistics") {
+ // not able to test result because the file cache may not be enabled
+ // in regression test.
+ // only execute the statement to make sure it won't fail.
+ sql "select * from information_schema.file_cache_statistics"
+ sql "select * from internal.information_schema.file_cache_statistics"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]