Coverage Report

Created: 2026-08-14 15:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/information_schema/schema_partitions_scanner.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "information_schema/schema_partitions_scanner.h"
19
20
#include <stdint.h>
21
22
#include "core/string_ref.h"
23
#include "core/value/decimalv2_value.h"
24
25
namespace doris {
26
27
std::vector<SchemaScanner::ColumnDesc> SchemaPartitionsScanner::_s_tbls_columns = {
28
        //   name,       type,          size,     is_null
29
        {"PARTITION_ID", TYPE_BIGINT, sizeof(int64_t), true},
30
        {"TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringRef), true},
31
        {"TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringRef), true},
32
        {"TABLE_NAME", TYPE_VARCHAR, sizeof(StringRef), false},
33
        {"PARTITION_NAME", TYPE_VARCHAR, sizeof(StringRef), true},
34
        {"SUBPARTITION_NAME", TYPE_VARCHAR, sizeof(StringRef), true},
35
        {"PARTITION_ORDINAL_POSITION", TYPE_INT, sizeof(int32_t), true},
36
        {"SUBPARTITION_ORDINAL_POSITION", TYPE_INT, sizeof(int32_t), true},
37
        {"PARTITION_METHOD", TYPE_VARCHAR, sizeof(StringRef), true},
38
        {"SUBPARTITION_METHOD", TYPE_VARCHAR, sizeof(StringRef), true},
39
        {"PARTITION_EXPRESSION", TYPE_VARCHAR, sizeof(StringRef), true},
40
        {"SUBPARTITION_EXPRESSION", TYPE_VARCHAR, sizeof(StringRef), true},
41
        {"PARTITION_DESCRIPTION", TYPE_STRING, sizeof(StringRef), true},
42
        {"TABLE_ROWS", TYPE_BIGINT, sizeof(int64_t), true},
43
        {"AVG_ROW_LENGTH", TYPE_BIGINT, sizeof(int64_t), true},
44
        {"DATA_LENGTH", TYPE_BIGINT, sizeof(int64_t), true},
45
        {"MAX_DATA_LENGTH", TYPE_BIGINT, sizeof(int64_t), true},
46
        {"INDEX_LENGTH", TYPE_BIGINT, sizeof(int64_t), true},
47
        {"DATA_FREE", TYPE_BIGINT, sizeof(int64_t), true},
48
        {"CREATE_TIME", TYPE_BIGINT, sizeof(int64_t), false},
49
        {"UPDATE_TIME", TYPE_DATETIME, sizeof(int128_t), true},
50
        {"CHECK_TIME", TYPE_DATETIME, sizeof(int128_t), true},
51
        {"CHECKSUM", TYPE_BIGINT, sizeof(int64_t), true},
52
        {"PARTITION_COMMENT", TYPE_STRING, sizeof(StringRef), false},
53
        {"NODEGROUP", TYPE_VARCHAR, sizeof(StringRef), true},
54
        {"TABLESPACE_NAME", TYPE_VARCHAR, sizeof(StringRef), true},
55
        {"LOCAL_DATA_SIZE", TYPE_STRING, sizeof(StringRef), true},
56
        {"REMOTE_DATA_SIZE", TYPE_STRING, sizeof(StringRef), true},
57
        {"STATE", TYPE_STRING, sizeof(StringRef), true},
58
        {"REPLICA_ALLOCATION", TYPE_STRING, sizeof(StringRef), true},
59
        {"REPLICA_NUM", TYPE_INT, sizeof(int32_t), true},
60
        {"STORAGE_POLICY", TYPE_STRING, sizeof(StringRef), true},
61
        {"STORAGE_MEDIUM", TYPE_STRING, sizeof(StringRef), true},
62
        {"COOLDOWN_TIME_MS", TYPE_STRING, sizeof(StringRef), true},
63
        {"LAST_CONSISTENCY_CHECK_TIME", TYPE_STRING, sizeof(StringRef), true},
64
        {"BUCKET_NUM", TYPE_INT, sizeof(int32_t), true},
65
        {"COMMITTED_VERSION", TYPE_BIGINT, sizeof(int64_t), true},
66
        {"VISIBLE_VERSION", TYPE_BIGINT, sizeof(int64_t), true},
67
        {"PARTITION_KEY", TYPE_STRING, sizeof(StringRef), true},
68
        {"RANGE", TYPE_STRING, sizeof(StringRef), true},
69
        {"DISTRIBUTION", TYPE_STRING, sizeof(StringRef), true},
70
};
71
72
SchemaPartitionsScanner::SchemaPartitionsScanner()
73
0
        : SchemaPerDbScanner(_s_tbls_columns, TSchemaTableType::SCH_PARTITIONS,
74
0
                             TSchemaTableName::PARTITIONS, "partitions") {}
75
76
0
void SchemaPartitionsScanner::add_extra_request_params(TSchemaTableRequestParams* params) {
77
0
    if (_param->common_param->thread_id > 0) {
78
0
        params->__set_thread_id(_param->common_param->thread_id);
79
0
    }
80
    // The FE renders partition timestamps, so it has to know which time zone to render in.
81
0
    params->__set_time_zone(_timezone);
82
0
}
83
84
} // namespace doris