Coverage Report

Created: 2025-10-28 13:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/olap/tablet_schema.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 "olap/tablet_schema.h"
19
20
#include <gen_cpp/Descriptors_types.h>
21
#include <gen_cpp/olap_file.pb.h>
22
#include <glog/logging.h>
23
#include <google/protobuf/io/coded_stream.h>
24
#include <google/protobuf/io/zero_copy_stream.h>
25
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
26
27
#include <algorithm>
28
#include <cctype>
29
// IWYU pragma: no_include <bits/std_abs.h>
30
#include <cmath> // IWYU pragma: keep
31
#include <memory>
32
#include <ostream>
33
#include <vector>
34
35
#include "common/compiler_util.h" // IWYU pragma: keep
36
#include "common/consts.h"
37
#include "common/status.h"
38
#include "exec/tablet_info.h"
39
#include "olap/inverted_index_parser.h"
40
#include "olap/olap_common.h"
41
#include "olap/olap_define.h"
42
#include "olap/tablet_column_object_pool.h"
43
#include "olap/types.h"
44
#include "olap/utils.h"
45
#include "tablet_meta.h"
46
#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
47
#include "vec/aggregate_functions/aggregate_function_state_union.h"
48
#include "vec/columns/column_nothing.h"
49
#include "vec/common/hex.h"
50
#include "vec/common/string_ref.h"
51
#include "vec/core/block.h"
52
#include "vec/data_types/data_type.h"
53
#include "vec/data_types/data_type_factory.hpp"
54
#include "vec/json/path_in_data.h"
55
56
namespace doris {
57
#include "common/compile_check_begin.h"
58
55.8k
FieldType TabletColumn::get_field_type_by_type(PrimitiveType primitiveType) {
59
55.8k
    switch (primitiveType) {
60
0
    case PrimitiveType::INVALID_TYPE:
61
0
        return FieldType::OLAP_FIELD_TYPE_UNKNOWN;
62
0
    case PrimitiveType::TYPE_NULL:
63
0
        return FieldType::OLAP_FIELD_TYPE_NONE;
64
0
    case PrimitiveType::TYPE_BOOLEAN:
65
0
        return FieldType::OLAP_FIELD_TYPE_BOOL;
66
55.7k
    case PrimitiveType::TYPE_TINYINT:
67
55.7k
        return FieldType::OLAP_FIELD_TYPE_TINYINT;
68
69
    case PrimitiveType::TYPE_SMALLINT:
69
69
        return FieldType::OLAP_FIELD_TYPE_SMALLINT;
70
5
    case PrimitiveType::TYPE_INT:
71
5
        return FieldType::OLAP_FIELD_TYPE_INT;
72
6
    case PrimitiveType::TYPE_BIGINT:
73
6
        return FieldType::OLAP_FIELD_TYPE_BIGINT;
74
0
    case PrimitiveType::TYPE_LARGEINT:
75
0
        return FieldType::OLAP_FIELD_TYPE_LARGEINT;
76
0
    case PrimitiveType::TYPE_FLOAT:
77
0
        return FieldType::OLAP_FIELD_TYPE_FLOAT;
78
12
    case PrimitiveType::TYPE_DOUBLE:
79
12
        return FieldType::OLAP_FIELD_TYPE_DOUBLE;
80
0
    case PrimitiveType::TYPE_VARCHAR:
81
0
        return FieldType::OLAP_FIELD_TYPE_VARCHAR;
82
0
    case PrimitiveType::TYPE_DATE:
83
0
        return FieldType::OLAP_FIELD_TYPE_DATE;
84
0
    case PrimitiveType::TYPE_DATETIME:
85
0
        return FieldType::OLAP_FIELD_TYPE_DATETIME;
86
0
    case PrimitiveType::TYPE_BINARY:
87
0
        return FieldType::OLAP_FIELD_TYPE_UNKNOWN; // Not implemented
88
0
    case PrimitiveType::TYPE_CHAR:
89
0
        return FieldType::OLAP_FIELD_TYPE_CHAR;
90
0
    case PrimitiveType::TYPE_STRUCT:
91
0
        return FieldType::OLAP_FIELD_TYPE_STRUCT;
92
0
    case PrimitiveType::TYPE_ARRAY:
93
0
        return FieldType::OLAP_FIELD_TYPE_ARRAY;
94
0
    case PrimitiveType::TYPE_MAP:
95
0
        return FieldType::OLAP_FIELD_TYPE_MAP;
96
0
    case PrimitiveType::TYPE_HLL:
97
0
        return FieldType::OLAP_FIELD_TYPE_HLL;
98
0
    case PrimitiveType::TYPE_DECIMALV2:
99
0
        return FieldType::OLAP_FIELD_TYPE_UNKNOWN; // Not implemented
100
0
    case PrimitiveType::TYPE_BITMAP:
101
0
        return FieldType::OLAP_FIELD_TYPE_BITMAP;
102
0
    case PrimitiveType::TYPE_STRING:
103
0
        return FieldType::OLAP_FIELD_TYPE_STRING;
104
0
    case PrimitiveType::TYPE_QUANTILE_STATE:
105
0
        return FieldType::OLAP_FIELD_TYPE_QUANTILE_STATE;
106
0
    case PrimitiveType::TYPE_DATEV2:
107
0
        return FieldType::OLAP_FIELD_TYPE_DATEV2;
108
0
    case PrimitiveType::TYPE_DATETIMEV2:
109
0
        return FieldType::OLAP_FIELD_TYPE_DATETIMEV2;
110
0
    case PrimitiveType::TYPE_TIMEV2:
111
0
        return FieldType::OLAP_FIELD_TYPE_TIMEV2;
112
0
    case PrimitiveType::TYPE_DECIMAL32:
113
0
        return FieldType::OLAP_FIELD_TYPE_DECIMAL32;
114
0
    case PrimitiveType::TYPE_DECIMAL64:
115
0
        return FieldType::OLAP_FIELD_TYPE_DECIMAL64;
116
0
    case PrimitiveType::TYPE_DECIMAL128I:
117
0
        return FieldType::OLAP_FIELD_TYPE_DECIMAL128I;
118
0
    case PrimitiveType::TYPE_DECIMAL256:
119
0
        return FieldType::OLAP_FIELD_TYPE_DECIMAL256;
120
0
    case PrimitiveType::TYPE_JSONB:
121
0
        return FieldType::OLAP_FIELD_TYPE_JSONB;
122
0
    case PrimitiveType::TYPE_VARIANT:
123
0
        return FieldType::OLAP_FIELD_TYPE_VARIANT;
124
0
    case PrimitiveType::TYPE_IPV4:
125
0
        return FieldType::OLAP_FIELD_TYPE_IPV4;
126
0
    case PrimitiveType::TYPE_IPV6:
127
0
        return FieldType::OLAP_FIELD_TYPE_IPV6;
128
0
    case PrimitiveType::TYPE_LAMBDA_FUNCTION:
129
0
        return FieldType::OLAP_FIELD_TYPE_UNKNOWN; // Not implemented
130
0
    case PrimitiveType::TYPE_AGG_STATE:
131
0
        return FieldType::OLAP_FIELD_TYPE_AGG_STATE;
132
0
    default:
133
0
        return FieldType::OLAP_FIELD_TYPE_UNKNOWN;
134
55.8k
    }
135
55.8k
}
136
137
25.0k
PrimitiveType TabletColumn::get_primitive_type_by_field_type(FieldType type) {
138
25.0k
    static const PrimitiveType mapping[] = {
139
25.0k
            /*  0 */ PrimitiveType::INVALID_TYPE,
140
25.0k
            /*  1 OLAP_FIELD_TYPE_TINYINT           */ PrimitiveType::TYPE_TINYINT,
141
25.0k
            /*  2 OLAP_FIELD_TYPE_UNSIGNED_TINYINT  */ PrimitiveType::INVALID_TYPE,
142
25.0k
            /*  3 OLAP_FIELD_TYPE_SMALLINT          */ PrimitiveType::TYPE_SMALLINT,
143
25.0k
            /*  4 OLAP_FIELD_TYPE_UNSIGNED_SMALLINT */ PrimitiveType::INVALID_TYPE,
144
25.0k
            /*  5 OLAP_FIELD_TYPE_INT               */ PrimitiveType::TYPE_INT,
145
25.0k
            /*  6 OLAP_FIELD_TYPE_UNSIGNED_INT      */ PrimitiveType::INVALID_TYPE,
146
25.0k
            /*  7 OLAP_FIELD_TYPE_BIGINT            */ PrimitiveType::TYPE_BIGINT,
147
25.0k
            /*  8 OLAP_FIELD_TYPE_UNSIGNED_BIGINT   */ PrimitiveType::INVALID_TYPE,
148
25.0k
            /*  9 OLAP_FIELD_TYPE_LARGEINT          */ PrimitiveType::TYPE_LARGEINT,
149
25.0k
            /* 10 OLAP_FIELD_TYPE_FLOAT             */ PrimitiveType::TYPE_FLOAT,
150
25.0k
            /* 11 OLAP_FIELD_TYPE_DOUBLE            */ PrimitiveType::TYPE_DOUBLE,
151
25.0k
            /* 12 OLAP_FIELD_TYPE_DISCRETE_DOUBLE   */ PrimitiveType::INVALID_TYPE,
152
25.0k
            /* 13 OLAP_FIELD_TYPE_CHAR              */ PrimitiveType::TYPE_CHAR,
153
25.0k
            /* 14 OLAP_FIELD_TYPE_DATE              */ PrimitiveType::TYPE_DATE,
154
25.0k
            /* 15 OLAP_FIELD_TYPE_DATETIME          */ PrimitiveType::TYPE_DATETIME,
155
25.0k
            /* 16 OLAP_FIELD_TYPE_DECIMAL           */ PrimitiveType::INVALID_TYPE,
156
25.0k
            /* 17 OLAP_FIELD_TYPE_VARCHAR           */ PrimitiveType::TYPE_VARCHAR,
157
25.0k
            /* 18 OLAP_FIELD_TYPE_STRUCT            */ PrimitiveType::TYPE_STRUCT,
158
25.0k
            /* 19 OLAP_FIELD_TYPE_ARRAY             */ PrimitiveType::TYPE_ARRAY,
159
25.0k
            /* 20 OLAP_FIELD_TYPE_MAP               */ PrimitiveType::TYPE_MAP,
160
25.0k
            /* 21 OLAP_FIELD_TYPE_UNKNOWN           */ PrimitiveType::INVALID_TYPE,
161
25.0k
            /* 22 OLAP_FIELD_TYPE_NONE              */ PrimitiveType::TYPE_NULL,
162
25.0k
            /* 23 OLAP_FIELD_TYPE_HLL               */ PrimitiveType::TYPE_HLL,
163
25.0k
            /* 24 OLAP_FIELD_TYPE_BOOL              */ PrimitiveType::TYPE_BOOLEAN,
164
25.0k
            /* 25 OLAP_FIELD_TYPE_BITMAP            */ PrimitiveType::TYPE_BITMAP,
165
25.0k
            /* 26 OLAP_FIELD_TYPE_STRING            */ PrimitiveType::TYPE_STRING,
166
25.0k
            /* 27 OLAP_FIELD_TYPE_QUANTILE_STATE    */ PrimitiveType::TYPE_QUANTILE_STATE,
167
25.0k
            /* 28 OLAP_FIELD_TYPE_DATEV2            */ PrimitiveType::TYPE_DATEV2,
168
25.0k
            /* 29 OLAP_FIELD_TYPE_DATETIMEV2        */ PrimitiveType::TYPE_DATETIMEV2,
169
25.0k
            /* 30 OLAP_FIELD_TYPE_TIMEV2            */ PrimitiveType::TYPE_TIMEV2,
170
25.0k
            /* 31 OLAP_FIELD_TYPE_DECIMAL32         */ PrimitiveType::TYPE_DECIMAL32,
171
25.0k
            /* 32 OLAP_FIELD_TYPE_DECIMAL64         */ PrimitiveType::TYPE_DECIMAL64,
172
25.0k
            /* 33 OLAP_FIELD_TYPE_DECIMAL128I       */ PrimitiveType::TYPE_DECIMAL128I,
173
25.0k
            /* 34 OLAP_FIELD_TYPE_JSONB             */ PrimitiveType::TYPE_JSONB,
174
25.0k
            /* 35 OLAP_FIELD_TYPE_VARIANT           */ PrimitiveType::TYPE_VARIANT,
175
25.0k
            /* 36 OLAP_FIELD_TYPE_AGG_STATE         */ PrimitiveType::TYPE_AGG_STATE,
176
25.0k
            /* 37 OLAP_FIELD_TYPE_DECIMAL256        */ PrimitiveType::TYPE_DECIMAL256,
177
25.0k
            /* 38 OLAP_FIELD_TYPE_IPV4              */ PrimitiveType::TYPE_IPV4,
178
25.0k
            /* 39 OLAP_FIELD_TYPE_IPV6              */ PrimitiveType::TYPE_IPV6,
179
25.0k
    };
180
181
25.0k
    int idx = static_cast<int>(type);
182
25.0k
    return mapping[idx];
183
25.0k
}
184
185
12.3k
FieldType TabletColumn::get_field_type_by_string(const std::string& type_str) {
186
12.3k
    std::string upper_type_str = type_str;
187
12.3k
    std::transform(type_str.begin(), type_str.end(), upper_type_str.begin(),
188
69.2k
                   [](auto c) { return std::toupper(c); });
189
12.3k
    FieldType type;
190
191
12.3k
    if (0 == upper_type_str.compare("TINYINT")) {
192
430
        type = FieldType::OLAP_FIELD_TYPE_TINYINT;
193
11.9k
    } else if (0 == upper_type_str.compare("SMALLINT")) {
194
876
        type = FieldType::OLAP_FIELD_TYPE_SMALLINT;
195
11.0k
    } else if (0 == upper_type_str.compare("INT")) {
196
2.55k
        type = FieldType::OLAP_FIELD_TYPE_INT;
197
8.50k
    } else if (0 == upper_type_str.compare("BIGINT")) {
198
182
        type = FieldType::OLAP_FIELD_TYPE_BIGINT;
199
8.32k
    } else if (0 == upper_type_str.compare("LARGEINT")) {
200
137
        type = FieldType::OLAP_FIELD_TYPE_LARGEINT;
201
8.18k
    } else if (0 == upper_type_str.compare("UNSIGNED_TINYINT")) {
202
0
        type = FieldType::OLAP_FIELD_TYPE_UNSIGNED_TINYINT;
203
8.18k
    } else if (0 == upper_type_str.compare("UNSIGNED_SMALLINT")) {
204
0
        type = FieldType::OLAP_FIELD_TYPE_UNSIGNED_SMALLINT;
205
8.18k
    } else if (0 == upper_type_str.compare("UNSIGNED_INT")) {
206
0
        type = FieldType::OLAP_FIELD_TYPE_UNSIGNED_INT;
207
8.18k
    } else if (0 == upper_type_str.compare("UNSIGNED_BIGINT")) {
208
0
        type = FieldType::OLAP_FIELD_TYPE_UNSIGNED_BIGINT;
209
8.18k
    } else if (0 == upper_type_str.compare("IPV4")) {
210
14
        type = FieldType::OLAP_FIELD_TYPE_IPV4;
211
8.17k
    } else if (0 == upper_type_str.compare("IPV6")) {
212
14
        type = FieldType::OLAP_FIELD_TYPE_IPV6;
213
8.15k
    } else if (0 == upper_type_str.compare("FLOAT")) {
214
0
        type = FieldType::OLAP_FIELD_TYPE_FLOAT;
215
8.15k
    } else if (0 == upper_type_str.compare("DISCRETE_DOUBLE")) {
216
0
        type = FieldType::OLAP_FIELD_TYPE_DISCRETE_DOUBLE;
217
8.15k
    } else if (0 == upper_type_str.compare("DOUBLE")) {
218
0
        type = FieldType::OLAP_FIELD_TYPE_DOUBLE;
219
8.15k
    } else if (0 == upper_type_str.compare("CHAR")) {
220
138
        type = FieldType::OLAP_FIELD_TYPE_CHAR;
221
8.01k
    } else if (0 == upper_type_str.compare("DATE")) {
222
140
        type = FieldType::OLAP_FIELD_TYPE_DATE;
223
7.87k
    } else if (0 == upper_type_str.compare("DATEV2")) {
224
133
        type = FieldType::OLAP_FIELD_TYPE_DATEV2;
225
7.74k
    } else if (0 == upper_type_str.compare("DATETIMEV2")) {
226
0
        type = FieldType::OLAP_FIELD_TYPE_DATETIMEV2;
227
7.74k
    } else if (0 == upper_type_str.compare("DATETIME")) {
228
167
        type = FieldType::OLAP_FIELD_TYPE_DATETIME;
229
7.57k
    } else if (0 == upper_type_str.compare("DECIMAL32")) {
230
0
        type = FieldType::OLAP_FIELD_TYPE_DECIMAL32;
231
7.57k
    } else if (0 == upper_type_str.compare("DECIMAL64")) {
232
0
        type = FieldType::OLAP_FIELD_TYPE_DECIMAL64;
233
7.57k
    } else if (0 == upper_type_str.compare("DECIMAL128I")) {
234
0
        type = FieldType::OLAP_FIELD_TYPE_DECIMAL128I;
235
7.57k
    } else if (0 == upper_type_str.compare("DECIMAL256")) {
236
0
        type = FieldType::OLAP_FIELD_TYPE_DECIMAL256;
237
7.57k
    } else if (0 == upper_type_str.compare(0, 7, "DECIMAL")) {
238
141
        type = FieldType::OLAP_FIELD_TYPE_DECIMAL;
239
7.43k
    } else if (0 == upper_type_str.compare(0, 7, "VARCHAR")) {
240
208
        type = FieldType::OLAP_FIELD_TYPE_VARCHAR;
241
7.22k
    } else if (0 == upper_type_str.compare("STRING")) {
242
7.16k
        type = FieldType::OLAP_FIELD_TYPE_STRING;
243
7.16k
    } else if (0 == upper_type_str.compare("JSONB")) {
244
0
        type = FieldType::OLAP_FIELD_TYPE_JSONB;
245
60
    } else if (0 == upper_type_str.compare("VARIANT")) {
246
51
        type = FieldType::OLAP_FIELD_TYPE_VARIANT;
247
51
    } else if (0 == upper_type_str.compare("BOOLEAN")) {
248
0
        type = FieldType::OLAP_FIELD_TYPE_BOOL;
249
9
    } else if (0 == upper_type_str.compare(0, 3, "HLL")) {
250
7
        type = FieldType::OLAP_FIELD_TYPE_HLL;
251
7
    } else if (0 == upper_type_str.compare("STRUCT")) {
252
0
        type = FieldType::OLAP_FIELD_TYPE_STRUCT;
253
2
    } else if (0 == upper_type_str.compare("LIST")) {
254
0
        type = FieldType::OLAP_FIELD_TYPE_ARRAY;
255
2
    } else if (0 == upper_type_str.compare("MAP")) {
256
0
        type = FieldType::OLAP_FIELD_TYPE_MAP;
257
2
    } else if (0 == upper_type_str.compare("OBJECT")) {
258
0
        type = FieldType::OLAP_FIELD_TYPE_BITMAP;
259
2
    } else if (0 == upper_type_str.compare("BITMAP")) {
260
0
        type = FieldType::OLAP_FIELD_TYPE_BITMAP;
261
2
    } else if (0 == upper_type_str.compare("ARRAY")) {
262
2
        type = FieldType::OLAP_FIELD_TYPE_ARRAY;
263
2
    } else if (0 == upper_type_str.compare("QUANTILE_STATE")) {
264
0
        type = FieldType::OLAP_FIELD_TYPE_QUANTILE_STATE;
265
0
    } else if (0 == upper_type_str.compare("AGG_STATE")) {
266
0
        type = FieldType::OLAP_FIELD_TYPE_AGG_STATE;
267
0
    } else {
268
0
        LOG(WARNING) << "invalid type string. [type='" << type_str << "']";
269
0
        type = FieldType::OLAP_FIELD_TYPE_UNKNOWN;
270
0
    }
271
272
12.3k
    return type;
273
12.3k
}
274
275
4.02k
FieldAggregationMethod TabletColumn::get_aggregation_type_by_string(const std::string& str) {
276
4.02k
    std::string upper_str = str;
277
4.02k
    std::transform(str.begin(), str.end(), upper_str.begin(),
278
20.7k
                   [](auto c) { return std::toupper(c); });
279
4.02k
    FieldAggregationMethod aggregation_type;
280
281
4.02k
    if (0 == upper_str.compare("NONE")) {
282
1.71k
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_NONE;
283
2.31k
    } else if (0 == upper_str.compare("SUM")) {
284
572
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_SUM;
285
1.74k
    } else if (0 == upper_str.compare("MIN")) {
286
4
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_MIN;
287
1.73k
    } else if (0 == upper_str.compare("MAX")) {
288
4
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_MAX;
289
1.73k
    } else if (0 == upper_str.compare("REPLACE")) {
290
1.72k
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE;
291
1.72k
    } else if (0 == upper_str.compare("REPLACE_IF_NOT_NULL")) {
292
0
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE_IF_NOT_NULL;
293
7
    } else if (0 == upper_str.compare("HLL_UNION")) {
294
7
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_HLL_UNION;
295
7
    } else if (0 == upper_str.compare("BITMAP_UNION")) {
296
0
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_BITMAP_UNION;
297
0
    } else if (0 == upper_str.compare("QUANTILE_UNION")) {
298
0
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_QUANTILE_UNION;
299
0
    } else if (!upper_str.empty()) {
300
0
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_GENERIC;
301
0
    } else {
302
0
        aggregation_type = FieldAggregationMethod::OLAP_FIELD_AGGREGATION_UNKNOWN;
303
0
    }
304
305
4.02k
    return aggregation_type;
306
4.02k
}
307
308
31.6k
std::string TabletColumn::get_string_by_field_type(FieldType type) {
309
31.6k
    switch (type) {
310
1.65k
    case FieldType::OLAP_FIELD_TYPE_TINYINT:
311
1.65k
        return "TINYINT";
312
313
0
    case FieldType::OLAP_FIELD_TYPE_UNSIGNED_TINYINT:
314
0
        return "UNSIGNED_TINYINT";
315
316
3.63k
    case FieldType::OLAP_FIELD_TYPE_SMALLINT:
317
3.63k
        return "SMALLINT";
318
319
0
    case FieldType::OLAP_FIELD_TYPE_UNSIGNED_SMALLINT:
320
0
        return "UNSIGNED_SMALLINT";
321
322
8.93k
    case FieldType::OLAP_FIELD_TYPE_INT:
323
8.93k
        return "INT";
324
325
0
    case FieldType::OLAP_FIELD_TYPE_UNSIGNED_INT:
326
0
        return "UNSIGNED_INT";
327
328
844
    case FieldType::OLAP_FIELD_TYPE_BIGINT:
329
844
        return "BIGINT";
330
331
721
    case FieldType::OLAP_FIELD_TYPE_LARGEINT:
332
721
        return "LARGEINT";
333
334
0
    case FieldType::OLAP_FIELD_TYPE_UNSIGNED_BIGINT:
335
0
        return "UNSIGNED_BIGINT";
336
337
117
    case FieldType::OLAP_FIELD_TYPE_IPV4:
338
117
        return "IPV4";
339
340
117
    case FieldType::OLAP_FIELD_TYPE_IPV6:
341
117
        return "IPV6";
342
343
0
    case FieldType::OLAP_FIELD_TYPE_FLOAT:
344
0
        return "FLOAT";
345
346
0
    case FieldType::OLAP_FIELD_TYPE_DOUBLE:
347
0
        return "DOUBLE";
348
349
0
    case FieldType::OLAP_FIELD_TYPE_DISCRETE_DOUBLE:
350
0
        return "DISCRETE_DOUBLE";
351
352
721
    case FieldType::OLAP_FIELD_TYPE_CHAR:
353
721
        return "CHAR";
354
355
725
    case FieldType::OLAP_FIELD_TYPE_DATE:
356
725
        return "DATE";
357
358
670
    case FieldType::OLAP_FIELD_TYPE_DATEV2:
359
670
        return "DATEV2";
360
361
916
    case FieldType::OLAP_FIELD_TYPE_DATETIME:
362
916
        return "DATETIME";
363
364
0
    case FieldType::OLAP_FIELD_TYPE_DATETIMEV2:
365
0
        return "DATETIMEV2";
366
367
721
    case FieldType::OLAP_FIELD_TYPE_DECIMAL:
368
721
        return "DECIMAL";
369
370
0
    case FieldType::OLAP_FIELD_TYPE_DECIMAL32:
371
0
        return "DECIMAL32";
372
373
0
    case FieldType::OLAP_FIELD_TYPE_DECIMAL64:
374
0
        return "DECIMAL64";
375
376
0
    case FieldType::OLAP_FIELD_TYPE_DECIMAL128I:
377
0
        return "DECIMAL128I";
378
379
0
    case FieldType::OLAP_FIELD_TYPE_DECIMAL256:
380
0
        return "DECIMAL256";
381
382
977
    case FieldType::OLAP_FIELD_TYPE_VARCHAR:
383
977
        return "VARCHAR";
384
385
0
    case FieldType::OLAP_FIELD_TYPE_JSONB:
386
0
        return "JSONB";
387
388
105
    case FieldType::OLAP_FIELD_TYPE_VARIANT:
389
105
        return "VARIANT";
390
391
10.7k
    case FieldType::OLAP_FIELD_TYPE_STRING:
392
10.7k
        return "STRING";
393
394
0
    case FieldType::OLAP_FIELD_TYPE_BOOL:
395
0
        return "BOOLEAN";
396
397
6
    case FieldType::OLAP_FIELD_TYPE_HLL:
398
6
        return "HLL";
399
400
0
    case FieldType::OLAP_FIELD_TYPE_STRUCT:
401
0
        return "STRUCT";
402
403
4
    case FieldType::OLAP_FIELD_TYPE_ARRAY:
404
4
        return "ARRAY";
405
406
2
    case FieldType::OLAP_FIELD_TYPE_MAP:
407
2
        return "MAP";
408
409
0
    case FieldType::OLAP_FIELD_TYPE_BITMAP:
410
0
        return "OBJECT";
411
0
    case FieldType::OLAP_FIELD_TYPE_QUANTILE_STATE:
412
0
        return "QUANTILE_STATE";
413
0
    case FieldType::OLAP_FIELD_TYPE_AGG_STATE:
414
0
        return "AGG_STATE";
415
0
    default:
416
0
        return "UNKNOWN";
417
31.6k
    }
418
31.6k
}
419
420
1.18k
std::string TabletColumn::get_string_by_aggregation_type(FieldAggregationMethod type) {
421
1.18k
    switch (type) {
422
1.15k
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_NONE:
423
1.15k
        return "NONE";
424
425
9
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_SUM:
426
9
        return "SUM";
427
428
0
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_MIN:
429
0
        return "MIN";
430
431
0
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_MAX:
432
0
        return "MAX";
433
434
15
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE:
435
15
        return "REPLACE";
436
437
0
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE_IF_NOT_NULL:
438
0
        return "REPLACE_IF_NOT_NULL";
439
440
0
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_HLL_UNION:
441
0
        return "HLL_UNION";
442
443
0
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_BITMAP_UNION:
444
0
        return "BITMAP_UNION";
445
446
0
    case FieldAggregationMethod::OLAP_FIELD_AGGREGATION_QUANTILE_UNION:
447
0
        return "QUANTILE_UNION";
448
449
2
    default:
450
2
        return "UNKNOWN";
451
1.18k
    }
452
1.18k
}
453
454
2.16k
uint32_t TabletColumn::get_field_length_by_type(TPrimitiveType::type type, uint32_t string_length) {
455
2.16k
    switch (type) {
456
110
    case TPrimitiveType::TINYINT:
457
110
    case TPrimitiveType::BOOLEAN:
458
110
        return 1;
459
357
    case TPrimitiveType::SMALLINT:
460
357
        return 2;
461
842
    case TPrimitiveType::INT:
462
842
        return 4;
463
114
    case TPrimitiveType::BIGINT:
464
114
        return 8;
465
101
    case TPrimitiveType::LARGEINT:
466
101
        return 16;
467
13
    case TPrimitiveType::IPV4:
468
13
        return 4;
469
13
    case TPrimitiveType::IPV6:
470
13
        return 16;
471
101
    case TPrimitiveType::DATE:
472
101
        return 3;
473
92
    case TPrimitiveType::DATEV2:
474
92
        return 4;
475
109
    case TPrimitiveType::DATETIME:
476
109
        return 8;
477
0
    case TPrimitiveType::DATETIMEV2:
478
0
        return 8;
479
0
    case TPrimitiveType::FLOAT:
480
0
        return 4;
481
0
    case TPrimitiveType::DOUBLE:
482
0
        return 8;
483
0
    case TPrimitiveType::QUANTILE_STATE:
484
0
    case TPrimitiveType::BITMAP:
485
0
        return 16;
486
101
    case TPrimitiveType::CHAR:
487
101
        return string_length;
488
101
    case TPrimitiveType::VARCHAR:
489
101
    case TPrimitiveType::HLL:
490
101
    case TPrimitiveType::AGG_STATE:
491
101
        return string_length + sizeof(OLAP_VARCHAR_MAX_LENGTH);
492
4
    case TPrimitiveType::STRING:
493
4
    case TPrimitiveType::VARIANT:
494
4
        return string_length + sizeof(OLAP_STRING_MAX_LENGTH);
495
0
    case TPrimitiveType::JSONB:
496
0
        return string_length + sizeof(OLAP_JSONB_MAX_LENGTH);
497
0
    case TPrimitiveType::STRUCT:
498
        // Note that(xy): this is the length of struct type itself,
499
        // the length of its subtypes are not included.
500
0
        return OLAP_STRUCT_MAX_LENGTH;
501
7
    case TPrimitiveType::ARRAY:
502
7
        return OLAP_ARRAY_MAX_LENGTH;
503
0
    case TPrimitiveType::MAP:
504
0
        return OLAP_MAP_MAX_LENGTH;
505
0
    case TPrimitiveType::DECIMAL32:
506
0
        return 4;
507
0
    case TPrimitiveType::DECIMAL64:
508
0
        return 8;
509
0
    case TPrimitiveType::DECIMAL128I:
510
0
        return 16;
511
0
    case TPrimitiveType::DECIMAL256:
512
0
        return 32;
513
101
    case TPrimitiveType::DECIMALV2:
514
101
        return 12; // use 12 bytes in olap engine.
515
0
    default:
516
0
        LOG(WARNING) << "unknown field type. [type=" << type << "]";
517
0
        return 0;
518
2.16k
    }
519
2.16k
}
520
521
9
bool TabletColumn::has_char_type() const {
522
9
    switch (_type) {
523
3
    case FieldType::OLAP_FIELD_TYPE_CHAR: {
524
3
        return true;
525
0
    }
526
4
    case FieldType::OLAP_FIELD_TYPE_ARRAY:
527
4
    case FieldType::OLAP_FIELD_TYPE_MAP:
528
4
    case FieldType::OLAP_FIELD_TYPE_STRUCT: {
529
4
        return std::any_of(_sub_columns.begin(), _sub_columns.end(),
530
4
                           [&](const auto& sub) -> bool { return sub->has_char_type(); });
531
4
    }
532
2
    default:
533
2
        return false;
534
9
    }
535
9
}
536
537
17.9k
TabletColumn::TabletColumn() : _aggregation(FieldAggregationMethod::OLAP_FIELD_AGGREGATION_NONE) {}
538
539
122
TabletColumn::TabletColumn(FieldAggregationMethod agg, FieldType type) {
540
122
    _aggregation = agg;
541
122
    _type = type;
542
122
}
543
544
17
TabletColumn::TabletColumn(FieldAggregationMethod agg, FieldType filed_type, bool is_nullable) {
545
17
    _aggregation = agg;
546
17
    _type = filed_type;
547
17
    _length = cast_set<int32_t>(get_scalar_type_info(filed_type)->size());
548
17
    _is_nullable = is_nullable;
549
17
}
550
551
TabletColumn::TabletColumn(FieldAggregationMethod agg, FieldType filed_type, bool is_nullable,
552
277
                           int32_t unique_id, size_t length) {
553
277
    _aggregation = agg;
554
277
    _type = filed_type;
555
277
    _is_nullable = is_nullable;
556
277
    _unique_id = unique_id;
557
277
    _length = cast_set<int32_t>(length);
558
277
}
559
560
0
TabletColumn::TabletColumn(const ColumnPB& column) {
561
0
    init_from_pb(column);
562
0
}
563
564
4
TabletColumn::TabletColumn(const TColumn& column) {
565
4
    init_from_thrift(column);
566
4
}
567
568
5
void TabletColumn::init_from_thrift(const TColumn& tcolumn) {
569
5
    ColumnPB column_pb;
570
5
    TabletMeta::init_column_from_tcolumn(tcolumn.col_unique_id, tcolumn, &column_pb);
571
5
    init_from_pb(column_pb);
572
5
}
573
574
12.2k
void TabletColumn::init_from_pb(const ColumnPB& column) {
575
12.2k
    _unique_id = column.unique_id();
576
12.2k
    _col_name = column.name();
577
12.2k
    _col_name_lower_case = to_lower(_col_name);
578
12.2k
    _type = TabletColumn::get_field_type_by_string(column.type());
579
12.2k
    _is_key = column.is_key();
580
12.2k
    _is_nullable = column.is_nullable();
581
12.2k
    _is_auto_increment = column.is_auto_increment();
582
12.2k
    if (column.has_is_on_update_current_timestamp()) {
583
11.3k
        _is_on_update_current_timestamp = column.is_on_update_current_timestamp();
584
11.3k
    }
585
586
12.2k
    _has_default_value = column.has_default_value();
587
12.2k
    if (_has_default_value) {
588
30
        _default_value = column.default_value();
589
30
    }
590
591
12.2k
    if (column.has_precision()) {
592
3.98k
        _is_decimal = true;
593
3.98k
        _precision = column.precision();
594
8.30k
    } else {
595
8.30k
        _is_decimal = false;
596
8.30k
    }
597
12.2k
    if (column.has_frac()) {
598
3.98k
        _frac = column.frac();
599
3.98k
    }
600
12.2k
    _length = column.length();
601
12.2k
    _index_length = column.index_length();
602
12.2k
    if (column.has_is_bf_column()) {
603
419
        _is_bf_column = column.is_bf_column();
604
11.8k
    } else {
605
11.8k
        _is_bf_column = false;
606
11.8k
    }
607
12.2k
    if (column.has_has_bitmap_index()) {
608
2.16k
        _has_bitmap_index = column.has_bitmap_index();
609
10.1k
    } else {
610
10.1k
        _has_bitmap_index = false;
611
10.1k
    }
612
12.2k
    if (column.has_aggregation()) {
613
4.02k
        _aggregation = get_aggregation_type_by_string(column.aggregation());
614
4.02k
        _aggregation_name = column.aggregation();
615
4.02k
    }
616
617
12.2k
    if (_type == FieldType::OLAP_FIELD_TYPE_AGG_STATE) {
618
0
        _result_is_nullable = column.result_is_nullable();
619
0
        _be_exec_version = column.be_exec_version();
620
0
    }
621
622
12.2k
    if (column.has_visible()) {
623
11.3k
        _visible = column.visible();
624
11.3k
    }
625
12.2k
    if (_type == FieldType::OLAP_FIELD_TYPE_ARRAY) {
626
2
        CHECK(column.children_columns_size() == 1)
627
0
                << "ARRAY type should has 1 children types, but got "
628
0
                << column.children_columns_size();
629
2
    }
630
12.2k
    if (_type == FieldType::OLAP_FIELD_TYPE_MAP) {
631
0
        DCHECK(column.children_columns_size() == 2)
632
0
                << "MAP type should has 2 children types, but got "
633
0
                << column.children_columns_size();
634
0
        if (UNLIKELY(column.children_columns_size() != 2)) {
635
0
            LOG(WARNING) << "MAP type should has 2 children types, but got "
636
0
                         << column.children_columns_size();
637
0
        }
638
0
    }
639
12.2k
    for (int i = 0; i < column.children_columns_size(); i++) {
640
6
        TabletColumn child_column;
641
6
        child_column.init_from_pb(column.children_columns(i));
642
6
        add_sub_column(child_column);
643
6
    }
644
12.2k
    if (column.has_column_path_info()) {
645
12
        _column_path = std::make_shared<vectorized::PathInData>();
646
12
        _column_path->from_protobuf(column.column_path_info());
647
12
        _parent_col_unique_id = column.column_path_info().parrent_column_unique_id();
648
12
    }
649
12.2k
    if (is_variant_type() && !column.has_column_path_info()) {
650
        // set path info for variant root column, to prevent from missing
651
39
        _column_path = std::make_shared<vectorized::PathInData>(_col_name_lower_case);
652
        // _parent_col_unique_id = _unique_id;
653
39
    }
654
12.2k
    if (column.has_variant_max_subcolumns_count()) {
655
11.3k
        _variant_max_subcolumns_count = column.variant_max_subcolumns_count();
656
11.3k
    }
657
12.2k
    if (column.has_variant_enable_typed_paths_to_sparse()) {
658
11.3k
        _variant_enable_typed_paths_to_sparse = column.variant_enable_typed_paths_to_sparse();
659
11.3k
    }
660
12.2k
    if (column.has_variant_max_sparse_column_statistics_size()) {
661
11.3k
        _variant_max_sparse_column_statistics_size =
662
11.3k
                column.variant_max_sparse_column_statistics_size();
663
11.3k
    }
664
12.2k
    if (column.has_pattern_type()) {
665
9.16k
        _pattern_type = column.pattern_type();
666
9.16k
    }
667
12.2k
}
668
669
TabletColumn TabletColumn::create_materialized_variant_column(const std::string& root,
670
                                                              const std::vector<std::string>& paths,
671
                                                              int32_t parent_unique_id,
672
0
                                                              int32_t max_subcolumns_count) {
673
0
    TabletColumn subcol;
674
0
    subcol.set_type(FieldType::OLAP_FIELD_TYPE_VARIANT);
675
0
    subcol.set_is_nullable(true);
676
0
    subcol.set_unique_id(-1);
677
0
    subcol.set_parent_unique_id(parent_unique_id);
678
0
    vectorized::PathInData path(root, paths);
679
0
    subcol.set_path_info(path);
680
0
    subcol.set_name(path.get_path());
681
0
    subcol.set_variant_max_subcolumns_count(max_subcolumns_count);
682
0
    return subcol;
683
0
}
684
685
31.6k
void TabletColumn::to_schema_pb(ColumnPB* column) const {
686
31.6k
    column->set_unique_id(_unique_id);
687
31.6k
    column->set_name(_col_name);
688
31.6k
    column->set_type(get_string_by_field_type(_type));
689
31.6k
    column->set_is_key(_is_key);
690
31.6k
    column->set_is_nullable(_is_nullable);
691
31.6k
    column->set_is_auto_increment(_is_auto_increment);
692
31.6k
    column->set_is_on_update_current_timestamp(_is_on_update_current_timestamp);
693
31.6k
    if (_has_default_value) {
694
156
        column->set_default_value(_default_value);
695
156
    }
696
31.6k
    if (_is_decimal) {
697
17.0k
        column->set_precision(_precision);
698
17.0k
        column->set_frac(_frac);
699
17.0k
    }
700
31.6k
    column->set_length(_length);
701
31.6k
    column->set_index_length(_index_length);
702
31.6k
    if (_is_bf_column) {
703
8
        column->set_is_bf_column(_is_bf_column);
704
8
    }
705
31.6k
    if (!_aggregation_name.empty()) {
706
17.1k
        column->set_aggregation(_aggregation_name);
707
17.1k
    }
708
31.6k
    column->set_result_is_nullable(_result_is_nullable);
709
31.6k
    column->set_be_exec_version(_be_exec_version);
710
31.6k
    if (_has_bitmap_index) {
711
0
        column->set_has_bitmap_index(_has_bitmap_index);
712
0
    }
713
31.6k
    column->set_visible(_visible);
714
715
31.6k
    if (_type == FieldType::OLAP_FIELD_TYPE_ARRAY) {
716
4
        CHECK(_sub_columns.size() == 1)
717
0
                << "ARRAY type should has 1 children types, but got " << _sub_columns.size();
718
4
    }
719
31.6k
    if (_type == FieldType::OLAP_FIELD_TYPE_MAP) {
720
0
        DCHECK(_sub_columns.size() == 2)
721
0
                << "MAP type should has 2 children types, but got " << _sub_columns.size();
722
0
        if (UNLIKELY(_sub_columns.size() != 2)) {
723
0
            LOG(WARNING) << "MAP type should has 2 children types, but got " << _sub_columns.size();
724
0
        }
725
0
    }
726
727
31.6k
    for (size_t i = 0; i < _sub_columns.size(); i++) {
728
8
        ColumnPB* child = column->add_children_columns();
729
8
        _sub_columns[i]->to_schema_pb(child);
730
8
    }
731
732
    // set parts info
733
31.6k
    if (has_path_info()) {
734
        // CHECK_GT(_parent_col_unique_id, 0);
735
100
        _column_path->to_protobuf(column->mutable_column_path_info(), _parent_col_unique_id);
736
        // Update unstable information for variant columns. Some of the fields in the tablet schema
737
        // are irrelevant for variant sub-columns, but retaining them may lead to an excessive growth
738
        // in the number of tablet schema cache entries.
739
100
        if (_type == FieldType::OLAP_FIELD_TYPE_STRING) {
740
0
            column->set_length(INT_MAX);
741
0
        }
742
100
        column->set_index_length(0);
743
100
    }
744
31.6k
    column->set_variant_max_subcolumns_count(_variant_max_subcolumns_count);
745
31.6k
    column->set_pattern_type(_pattern_type);
746
31.6k
    column->set_variant_enable_typed_paths_to_sparse(_variant_enable_typed_paths_to_sparse);
747
31.6k
    column->set_variant_max_sparse_column_statistics_size(
748
31.6k
            _variant_max_sparse_column_statistics_size);
749
31.6k
}
750
751
585
void TabletColumn::add_sub_column(TabletColumn& sub_column) {
752
585
    _sub_columns.push_back(std::make_shared<TabletColumn>(sub_column));
753
585
    sub_column._parent_col_unique_id = this->_unique_id;
754
585
    _sub_column_count += 1;
755
585
}
756
757
23.1k
bool TabletColumn::is_row_store_column() const {
758
23.1k
    return _col_name == BeConsts::ROW_STORE_COL;
759
23.1k
}
760
761
vectorized::AggregateFunctionPtr TabletColumn::get_aggregate_function_union(
762
0
        vectorized::DataTypePtr type, int current_be_exec_version) const {
763
0
    const auto* state_type = assert_cast<const vectorized::DataTypeAggState*>(type.get());
764
0
    BeExecVersionManager::check_function_compatibility(
765
0
            current_be_exec_version, _be_exec_version,
766
0
            state_type->get_nested_function()->get_name());
767
0
    return vectorized::AggregateStateUnion::create(state_type->get_nested_function(), {type}, type);
768
0
}
769
770
vectorized::AggregateFunctionPtr TabletColumn::get_aggregate_function(
771
24
        std::string suffix, int current_be_exec_version) const {
772
24
    vectorized::AggregateFunctionPtr function = nullptr;
773
774
24
    auto type = vectorized::DataTypeFactory::instance().create_data_type(*this);
775
24
    if (type && type->get_primitive_type() == PrimitiveType::TYPE_AGG_STATE) {
776
0
        function = get_aggregate_function_union(type, current_be_exec_version);
777
24
    } else {
778
24
        std::string origin_name = TabletColumn::get_string_by_aggregation_type(_aggregation);
779
24
        std::string agg_name = origin_name + suffix;
780
24
        std::transform(agg_name.begin(), agg_name.end(), agg_name.begin(),
781
258
                       [](unsigned char c) { return std::tolower(c); });
782
24
        function = vectorized::AggregateFunctionSimpleFactory::instance().get(
783
24
                agg_name, {type}, type->is_nullable(), BeExecVersionManager::get_newest_version());
784
24
        if (!function) {
785
0
            LOG(WARNING) << "get column aggregate function failed, aggregation_name=" << origin_name
786
0
                         << ", column_type=" << type->get_name();
787
0
        }
788
24
    }
789
24
    if (function) {
790
24
        function->set_version(_be_exec_version);
791
24
        return function;
792
24
    }
793
0
    return nullptr;
794
24
}
795
796
1.23k
void TabletColumn::set_path_info(const vectorized::PathInData& path) {
797
1.23k
    _column_path = std::make_shared<vectorized::PathInData>(path);
798
1.23k
}
799
800
167
vectorized::DataTypePtr TabletColumn::get_vec_type() const {
801
167
    return vectorized::DataTypeFactory::instance().create_data_type(*this);
802
167
}
803
804
// escape '.' and '_'
805
57.2k
std::string escape_for_path_name(const std::string& s) {
806
57.2k
    std::string res;
807
57.2k
    const char* pos = s.data();
808
57.2k
    const char* end = pos + s.size();
809
57.8k
    while (pos != end) {
810
609
        unsigned char c = *pos;
811
609
        if (c == '.' || c == '_') {
812
55
            res += '%';
813
55
            res += vectorized::hex_digit_uppercase(c / 16);
814
55
            res += vectorized::hex_digit_uppercase(c % 16);
815
554
        } else {
816
554
            res += c;
817
554
        }
818
609
        ++pos;
819
609
    }
820
57.2k
    return res;
821
57.2k
}
822
823
26
void TabletIndex::set_escaped_escaped_index_suffix_path(const std::string& path_name) {
824
26
    std::string escaped_path = escape_for_path_name(path_name);
825
26
    _escaped_index_suffix_path = escaped_path;
826
26
}
827
828
void TabletIndex::init_from_thrift(const TOlapTableIndex& index,
829
17
                                   const TabletSchema& tablet_schema) {
830
17
    _index_id = index.index_id;
831
17
    _index_name = index.index_name;
832
    // init col_unique_id in index at be side, since col_unique_id may be -1 at fe side
833
    // get column unique id by name
834
17
    std::vector<int32_t> col_unique_ids(index.columns.size());
835
34
    for (size_t i = 0; i < index.columns.size(); i++) {
836
17
        auto column_idx = tablet_schema.field_index(index.columns[i]);
837
17
        if (column_idx >= 0) {
838
13
            col_unique_ids[i] = tablet_schema.column(column_idx).unique_id();
839
13
        } else {
840
            // if column unique id not found by column name, find by column unique id
841
            // column unique id can not found means this column is a new column added by light schema change
842
4
            if (index.__isset.column_unique_ids && !index.column_unique_ids.empty() &&
843
4
                tablet_schema.has_column_unique_id(index.column_unique_ids[i])) {
844
1
                col_unique_ids[i] = index.column_unique_ids[i];
845
3
            } else {
846
3
                col_unique_ids[i] = -1;
847
3
            }
848
4
        }
849
17
    }
850
17
    _col_unique_ids = std::move(col_unique_ids);
851
852
17
    switch (index.index_type) {
853
0
    case TIndexType::BITMAP:
854
0
        _index_type = IndexType::BITMAP;
855
0
        break;
856
17
    case TIndexType::INVERTED:
857
17
        _index_type = IndexType::INVERTED;
858
17
        break;
859
0
    case TIndexType::ANN:
860
0
        _index_type = IndexType::ANN;
861
0
        break;
862
0
    case TIndexType::BLOOMFILTER:
863
0
        _index_type = IndexType::BLOOMFILTER;
864
0
        break;
865
0
    case TIndexType::NGRAM_BF:
866
0
        _index_type = IndexType::NGRAM_BF;
867
0
        break;
868
17
    }
869
17
    if (index.__isset.properties) {
870
0
        for (auto kv : index.properties) {
871
0
            _properties[kv.first] = kv.second;
872
0
        }
873
0
    }
874
17
}
875
876
void TabletIndex::init_from_thrift(const TOlapTableIndex& index,
877
1
                                   const std::vector<int32_t>& column_uids) {
878
1
    _index_id = index.index_id;
879
1
    _index_name = index.index_name;
880
1
    _col_unique_ids = column_uids;
881
882
1
    switch (index.index_type) {
883
0
    case TIndexType::BITMAP:
884
0
        _index_type = IndexType::BITMAP;
885
0
        break;
886
1
    case TIndexType::INVERTED:
887
1
        _index_type = IndexType::INVERTED;
888
1
        break;
889
0
    case TIndexType::ANN:
890
0
        _index_type = IndexType::ANN;
891
0
        break;
892
0
    case TIndexType::BLOOMFILTER:
893
0
        _index_type = IndexType::BLOOMFILTER;
894
0
        break;
895
0
    case TIndexType::NGRAM_BF:
896
0
        _index_type = IndexType::NGRAM_BF;
897
0
        break;
898
1
    }
899
1
    if (index.__isset.properties) {
900
3
        for (auto kv : index.properties) {
901
3
            _properties[kv.first] = kv.second;
902
3
        }
903
1
    }
904
1
}
905
906
7.45k
void TabletIndex::init_from_pb(const TabletIndexPB& index) {
907
7.45k
    _index_id = index.index_id();
908
7.45k
    _index_name = index.index_name();
909
7.45k
    _col_unique_ids.clear();
910
7.45k
    for (auto col_unique_id : index.col_unique_id()) {
911
7.42k
        _col_unique_ids.push_back(col_unique_id);
912
7.42k
    }
913
7.45k
    _index_type = index.index_type();
914
41.0k
    for (const auto& kv : index.properties()) {
915
41.0k
        _properties[kv.first] = kv.second;
916
41.0k
    }
917
7.45k
    _escaped_index_suffix_path = index.index_suffix_name();
918
7.45k
}
919
920
11.0k
void TabletIndex::to_schema_pb(TabletIndexPB* index) const {
921
11.0k
    index->set_index_id(_index_id);
922
11.0k
    index->set_index_name(_index_name);
923
11.0k
    index->clear_col_unique_id();
924
11.0k
    for (auto col_unique_id : _col_unique_ids) {
925
11.0k
        index->add_col_unique_id(col_unique_id);
926
11.0k
    }
927
11.0k
    index->set_index_type(_index_type);
928
60.8k
    for (const auto& kv : _properties) {
929
60.8k
        DBUG_EXECUTE_IF("tablet_schema.to_schema_pb", {
930
60.8k
            if (kv.first == INVERTED_INDEX_PARSER_LOWERCASE_KEY) {
931
60.8k
                continue;
932
60.8k
            }
933
60.8k
        })
934
60.8k
        (*index->mutable_properties())[kv.first] = kv.second;
935
60.8k
    }
936
11.0k
    index->set_index_suffix_name(_escaped_index_suffix_path);
937
938
11.0k
    DBUG_EXECUTE_IF("tablet_schema.to_schema_pb", { return; })
939
940
    // lowercase by default
941
11.0k
    if (!_properties.empty()) {
942
9.76k
        if (!_properties.contains(INVERTED_INDEX_PARSER_LOWERCASE_KEY)) {
943
176
            (*index->mutable_properties())[INVERTED_INDEX_PARSER_LOWERCASE_KEY] =
944
176
                    INVERTED_INDEX_PARSER_TRUE;
945
176
        }
946
9.76k
    }
947
11.0k
}
948
949
3.09k
TabletSchema::TabletSchema() = default;
950
951
3.03k
TabletSchema::~TabletSchema() {}
952
953
1.84k
int64_t TabletSchema::get_metadata_size() const {
954
1.84k
    return sizeof(TabletSchema);
955
1.84k
}
956
957
1.28k
void TabletSchema::append_column(TabletColumn column, ColumnType col_type) {
958
1.28k
    if (column.is_key()) {
959
109
        _num_key_columns++;
960
109
    }
961
1.28k
    if (column.is_nullable()) {
962
1.06k
        _num_null_columns++;
963
1.06k
    }
964
1.28k
    if (column.is_variant_type()) {
965
55
        ++_num_variant_columns;
966
55
        if (!column.has_path_info()) {
967
23
            const std::string& col_name = column.name_lower_case();
968
23
            vectorized::PathInData path(col_name);
969
23
            column.set_path_info(path);
970
23
        }
971
55
    }
972
1.28k
    if (UNLIKELY(column.name() == DELETE_SIGN)) {
973
21
        _delete_sign_idx = _num_columns;
974
1.26k
    } else if (UNLIKELY(column.name() == SEQUENCE_COL)) {
975
4
        _sequence_col_idx = _num_columns;
976
1.26k
    } else if (UNLIKELY(column.name() == VERSION_COL)) {
977
0
        _version_col_idx = _num_columns;
978
1.26k
    } else if (UNLIKELY(column.name() == SKIP_BITMAP_COL)) {
979
0
        _skip_bitmap_col_idx = _num_columns;
980
1.26k
    } else if (UNLIKELY(column.name().starts_with(BeConsts::VIRTUAL_COLUMN_PREFIX))) {
981
0
        _vir_col_idx_to_unique_id[_num_columns] = column.unique_id();
982
0
    }
983
1.28k
    _field_uniqueid_to_index[column.unique_id()] = _num_columns;
984
1.28k
    _cols.push_back(std::make_shared<TabletColumn>(std::move(column)));
985
    // The dropped column may have same name with exsiting column, so that
986
    // not add to name to index map, only for uid to index map
987
1.28k
    if (col_type == ColumnType::VARIANT || _cols.back()->is_variant_type() ||
988
1.28k
        _cols.back()->is_extracted_column()) {
989
110
        _field_name_to_index.emplace(StringRef(_cols.back()->name()), _num_columns);
990
110
        _field_path_to_index[_cols.back()->path_info_ptr().get()] = _num_columns;
991
1.17k
    } else if (col_type == ColumnType::NORMAL) {
992
1.17k
        _field_name_to_index.emplace(StringRef(_cols.back()->name()), _num_columns);
993
1.17k
    }
994
1.28k
    _num_columns++;
995
1.28k
    _num_virtual_columns = _vir_col_idx_to_unique_id.size();
996
1.28k
}
997
998
65
void TabletSchema::append_index(TabletIndex&& index) {
999
65
    size_t index_pos = _indexes.size();
1000
65
    _indexes.push_back(std::make_shared<TabletIndex>(index));
1001
68
    for (int32_t id : _indexes.back()->col_unique_ids()) {
1002
68
        if (auto field_pattern = _indexes.back()->field_pattern(); !field_pattern.empty()) {
1003
6
            auto& pattern_to_index_map = _index_by_unique_id_with_pattern[id];
1004
6
            pattern_to_index_map[field_pattern].emplace_back(_indexes.back());
1005
62
        } else {
1006
62
            IndexKey key = std::make_tuple(_indexes.back()->index_type(), id,
1007
62
                                           _indexes.back()->get_index_suffix());
1008
62
            _col_id_suffix_to_index[key].push_back(index_pos);
1009
62
        }
1010
68
    }
1011
65
}
1012
1013
0
void TabletSchema::replace_column(size_t pos, TabletColumn new_col) {
1014
0
    CHECK_LT(pos, num_columns()) << " outof range";
1015
0
    _cols[pos] = std::make_shared<TabletColumn>(std::move(new_col));
1016
0
}
1017
1018
3
void TabletSchema::clear_index() {
1019
3
    _indexes.clear();
1020
3
    _col_id_suffix_to_index.clear();
1021
3
    _index_by_unique_id_with_pattern.clear();
1022
3
}
1023
1024
5
void TabletSchema::remove_index(int64_t index_id) {
1025
5
    std::vector<TabletIndexPtr> new_indexes;
1026
8
    for (auto& index : _indexes) {
1027
8
        if (index->index_id() != index_id) {
1028
3
            new_indexes.emplace_back(std::move(index));
1029
3
        }
1030
8
    }
1031
5
    _indexes = std::move(new_indexes);
1032
5
    _col_id_suffix_to_index.clear();
1033
5
    _index_by_unique_id_with_pattern.clear();
1034
8
    for (size_t new_pos = 0; new_pos < _indexes.size(); ++new_pos) {
1035
3
        const auto& index = _indexes[new_pos];
1036
3
        for (int32_t col_uid : index->col_unique_ids()) {
1037
3
            if (auto field_pattern = index->field_pattern(); !field_pattern.empty()) {
1038
0
                auto& pattern_to_index_map = _index_by_unique_id_with_pattern[col_uid];
1039
0
                pattern_to_index_map[field_pattern].emplace_back(index);
1040
3
            } else {
1041
3
                IndexKey key = std::make_tuple(_indexes.back()->index_type(), col_uid,
1042
3
                                               _indexes.back()->get_index_suffix());
1043
3
                _col_id_suffix_to_index[key].push_back(new_pos);
1044
3
            }
1045
3
        }
1046
3
    }
1047
5
}
1048
1049
1
void TabletSchema::clear_columns() {
1050
1
    _field_path_to_index.clear();
1051
1
    _field_name_to_index.clear();
1052
1
    _field_uniqueid_to_index.clear();
1053
1
    _num_columns = 0;
1054
1
    _num_variant_columns = 0;
1055
1
    _num_null_columns = 0;
1056
1
    _num_key_columns = 0;
1057
1
    _cols.clear();
1058
1
}
1059
1060
void TabletSchema::init_from_pb(const TabletSchemaPB& schema, bool ignore_extracted_columns,
1061
1.78k
                                bool reuse_cache_column) {
1062
1.78k
    _keys_type = schema.keys_type();
1063
1.78k
    _num_columns = 0;
1064
1.78k
    _num_variant_columns = 0;
1065
1.78k
    _num_key_columns = 0;
1066
1.78k
    _num_null_columns = 0;
1067
1.78k
    _cols.clear();
1068
1.78k
    _indexes.clear();
1069
1.78k
    _index_by_unique_id_with_pattern.clear();
1070
1.78k
    _col_id_suffix_to_index.clear();
1071
1.78k
    _field_name_to_index.clear();
1072
1.78k
    _field_uniqueid_to_index.clear();
1073
1.78k
    _cluster_key_uids.clear();
1074
1.78k
    for (const auto& i : schema.cluster_key_uids()) {
1075
6
        _cluster_key_uids.push_back(i);
1076
6
    }
1077
12.4k
    for (auto& column_pb : schema.column()) {
1078
12.4k
        TabletColumnPtr column;
1079
12.4k
        if (reuse_cache_column) {
1080
320
            auto pair = TabletColumnObjectPool::instance()->insert(
1081
320
                    deterministic_string_serialize(column_pb));
1082
320
            column = pair.second;
1083
            // Release the handle quickly, because we use shared ptr to manage column.
1084
            // It often core during tablet schema copy to another schema because handle's
1085
            // reference count should be managed mannually.
1086
320
            TabletColumnObjectPool::instance()->release(pair.first);
1087
12.1k
        } else {
1088
12.1k
            column = std::make_shared<TabletColumn>();
1089
12.1k
            column->init_from_pb(column_pb);
1090
12.1k
        }
1091
12.4k
        if (ignore_extracted_columns && column->is_extracted_column()) {
1092
0
            continue;
1093
0
        }
1094
12.4k
        if (column->is_key()) {
1095
2.35k
            _num_key_columns++;
1096
2.35k
        }
1097
12.4k
        if (column->is_nullable()) {
1098
7.46k
            _num_null_columns++;
1099
7.46k
        }
1100
12.4k
        if (column->is_variant_type()) {
1101
54
            ++_num_variant_columns;
1102
54
        }
1103
1104
12.4k
        _cols.emplace_back(std::move(column));
1105
12.4k
        if (!_cols.back()->is_extracted_column()) {
1106
12.4k
            _field_name_to_index.emplace(StringRef(_cols.back()->name()), _num_columns);
1107
12.4k
            _field_uniqueid_to_index[_cols.back()->unique_id()] = _num_columns;
1108
12.4k
        }
1109
12.4k
        _num_columns++;
1110
12.4k
    }
1111
7.37k
    for (const auto& index_pb : schema.index()) {
1112
7.37k
        TabletIndexPtr index;
1113
7.37k
        if (reuse_cache_column) {
1114
149
            auto pair = TabletColumnObjectPool::instance()->insert_index(
1115
149
                    deterministic_string_serialize(index_pb));
1116
149
            index = pair.second;
1117
            //  Only need the value to be cached by the pool, release it quickly because the handle need
1118
            // record reference count mannually, or it will core during tablet schema copy method.
1119
149
            TabletColumnObjectPool::instance()->release(pair.first);
1120
7.22k
        } else {
1121
7.22k
            index = std::make_shared<TabletIndex>();
1122
7.22k
            index->init_from_pb(index_pb);
1123
7.22k
        }
1124
7.37k
        size_t index_pos = _indexes.size();
1125
7.37k
        _indexes.emplace_back(std::move(index));
1126
7.37k
        for (int32_t col_uid : _indexes.back()->col_unique_ids()) {
1127
7.37k
            if (auto field_pattern = _indexes.back()->field_pattern(); !field_pattern.empty()) {
1128
0
                auto& pattern_to_index_map = _index_by_unique_id_with_pattern[col_uid];
1129
0
                pattern_to_index_map[field_pattern].emplace_back(_indexes.back());
1130
7.37k
            } else {
1131
7.37k
                IndexKey key = std::make_tuple(_indexes.back()->index_type(), col_uid,
1132
7.37k
                                               _indexes.back()->get_index_suffix());
1133
7.37k
                _col_id_suffix_to_index[key].push_back(index_pos);
1134
7.37k
            }
1135
7.37k
        }
1136
7.37k
    }
1137
1.78k
    _num_short_key_columns = schema.num_short_key_columns();
1138
1.78k
    _num_rows_per_row_block = schema.num_rows_per_row_block();
1139
1.78k
    _compress_kind = schema.compress_kind();
1140
1.78k
    _next_column_unique_id = schema.next_column_unique_id();
1141
1.78k
    if (schema.has_bf_fpp()) {
1142
3
        _has_bf_fpp = true;
1143
3
        _bf_fpp = schema.bf_fpp();
1144
1.78k
    } else {
1145
1.78k
        _has_bf_fpp = false;
1146
1.78k
        _bf_fpp = BLOOM_FILTER_DEFAULT_FPP;
1147
1.78k
    }
1148
1.78k
    _is_in_memory = schema.is_in_memory();
1149
1.78k
    _disable_auto_compaction = schema.disable_auto_compaction();
1150
1.78k
    _enable_single_replica_compaction = schema.enable_single_replica_compaction();
1151
1.78k
    _store_row_column = schema.store_row_column();
1152
1.78k
    _skip_write_index_on_load = schema.skip_write_index_on_load();
1153
1.78k
    _delete_sign_idx = schema.delete_sign_idx();
1154
1.78k
    _sequence_col_idx = schema.sequence_col_idx();
1155
1.78k
    _version_col_idx = schema.version_col_idx();
1156
1.78k
    _skip_bitmap_col_idx = schema.skip_bitmap_col_idx();
1157
1.78k
    _sort_type = schema.sort_type();
1158
1.78k
    _sort_col_num = schema.sort_col_num();
1159
1.78k
    _compression_type = schema.compression_type();
1160
1.78k
    _row_store_page_size = schema.row_store_page_size();
1161
1.78k
    _storage_page_size = schema.storage_page_size();
1162
1.78k
    _storage_dict_page_size = schema.storage_dict_page_size();
1163
1.78k
    _schema_version = schema.schema_version();
1164
    // Default to V1 inverted index storage format for backward compatibility if not specified in schema.
1165
1.78k
    if (!schema.has_inverted_index_storage_format()) {
1166
260
        _inverted_index_storage_format = InvertedIndexStorageFormatPB::V1;
1167
1.52k
    } else {
1168
1.52k
        _inverted_index_storage_format = schema.inverted_index_storage_format();
1169
1.52k
    }
1170
1171
1.78k
    _row_store_column_unique_ids.assign(schema.row_store_column_unique_ids().begin(),
1172
1.78k
                                        schema.row_store_column_unique_ids().end());
1173
1.78k
    _enable_variant_flatten_nested = schema.enable_variant_flatten_nested();
1174
1.78k
    update_metadata_size();
1175
1.78k
}
1176
1177
382
void TabletSchema::copy_from(const TabletSchema& tablet_schema) {
1178
382
    TabletSchemaPB tablet_schema_pb;
1179
382
    tablet_schema.to_schema_pb(&tablet_schema_pb);
1180
382
    init_from_pb(tablet_schema_pb);
1181
382
    _table_id = tablet_schema.table_id();
1182
382
    _path_set_info_map = tablet_schema._path_set_info_map;
1183
382
}
1184
1185
42
void TabletSchema::shawdow_copy_without_columns(const TabletSchema& tablet_schema) {
1186
42
    *this = tablet_schema;
1187
42
    _field_path_to_index.clear();
1188
42
    _field_name_to_index.clear();
1189
42
    _field_uniqueid_to_index.clear();
1190
42
    _num_columns = 0;
1191
42
    _num_variant_columns = 0;
1192
42
    _num_null_columns = 0;
1193
42
    _num_key_columns = 0;
1194
42
    _cols.clear();
1195
42
    _delete_sign_idx = -1;
1196
42
    _sequence_col_idx = -1;
1197
42
    _version_col_idx = -1;
1198
42
}
1199
1200
0
void TabletSchema::update_index_info_from(const TabletSchema& tablet_schema) {
1201
0
    for (auto& col : _cols) {
1202
0
        if (col->unique_id() < 0) {
1203
0
            continue;
1204
0
        }
1205
0
        const auto iter = tablet_schema._field_uniqueid_to_index.find(col->unique_id());
1206
0
        if (iter == tablet_schema._field_uniqueid_to_index.end()) {
1207
0
            continue;
1208
0
        }
1209
0
        auto col_idx = iter->second;
1210
0
        if (col_idx < 0 || col_idx >= tablet_schema._cols.size()) {
1211
0
            continue;
1212
0
        }
1213
0
        col->set_is_bf_column(tablet_schema._cols[col_idx]->is_bf_column());
1214
0
        col->set_has_bitmap_index(tablet_schema._cols[col_idx]->has_bitmap_index());
1215
0
    }
1216
0
}
1217
1218
3.30k
std::string TabletSchema::to_key() const {
1219
3.30k
    TabletSchemaPB pb;
1220
3.30k
    to_schema_pb(&pb);
1221
3.30k
    return TabletSchema::deterministic_string_serialize(pb);
1222
3.30k
}
1223
1224
void TabletSchema::build_current_tablet_schema(int64_t index_id, int32_t version,
1225
                                               const OlapTableIndexSchema* index,
1226
0
                                               const TabletSchema& ori_tablet_schema) {
1227
    // copy from ori_tablet_schema
1228
0
    _keys_type = ori_tablet_schema.keys_type();
1229
0
    _num_short_key_columns = ori_tablet_schema.num_short_key_columns();
1230
0
    _num_rows_per_row_block = ori_tablet_schema.num_rows_per_row_block();
1231
0
    _compress_kind = ori_tablet_schema.compress_kind();
1232
1233
    // todo(yixiu): unique_id
1234
0
    _next_column_unique_id = ori_tablet_schema.next_column_unique_id();
1235
0
    _is_in_memory = ori_tablet_schema.is_in_memory();
1236
0
    _disable_auto_compaction = ori_tablet_schema.disable_auto_compaction();
1237
0
    _enable_single_replica_compaction = ori_tablet_schema.enable_single_replica_compaction();
1238
0
    _skip_write_index_on_load = ori_tablet_schema.skip_write_index_on_load();
1239
0
    _sort_type = ori_tablet_schema.sort_type();
1240
0
    _sort_col_num = ori_tablet_schema.sort_col_num();
1241
0
    _row_store_page_size = ori_tablet_schema.row_store_page_size();
1242
0
    _storage_page_size = ori_tablet_schema.storage_page_size();
1243
0
    _storage_dict_page_size = ori_tablet_schema.storage_dict_page_size();
1244
0
    _enable_variant_flatten_nested = ori_tablet_schema.variant_flatten_nested();
1245
1246
    // copy from table_schema_param
1247
0
    _schema_version = version;
1248
0
    _num_columns = 0;
1249
0
    _num_variant_columns = 0;
1250
0
    _num_key_columns = 0;
1251
0
    _num_null_columns = 0;
1252
0
    bool has_bf_columns = false;
1253
0
    _cols.clear();
1254
0
    _indexes.clear();
1255
0
    _col_id_suffix_to_index.clear();
1256
0
    _index_by_unique_id_with_pattern.clear();
1257
0
    _field_name_to_index.clear();
1258
0
    _field_uniqueid_to_index.clear();
1259
0
    _delete_sign_idx = -1;
1260
0
    _sequence_col_idx = -1;
1261
0
    _version_col_idx = -1;
1262
0
    _skip_bitmap_col_idx = -1;
1263
0
    _cluster_key_uids.clear();
1264
0
    for (const auto& i : ori_tablet_schema._cluster_key_uids) {
1265
0
        _cluster_key_uids.push_back(i);
1266
0
    }
1267
0
    for (auto& column : index->columns) {
1268
0
        if (column->is_key()) {
1269
0
            _num_key_columns++;
1270
0
        }
1271
0
        if (column->is_nullable()) {
1272
0
            _num_null_columns++;
1273
0
        }
1274
0
        if (column->is_bf_column()) {
1275
0
            has_bf_columns = true;
1276
0
        }
1277
0
        if (column->is_variant_type()) {
1278
0
            ++_num_variant_columns;
1279
0
        }
1280
0
        if (UNLIKELY(column->name() == DELETE_SIGN)) {
1281
0
            _delete_sign_idx = _num_columns;
1282
0
        } else if (UNLIKELY(column->name() == SEQUENCE_COL)) {
1283
0
            _sequence_col_idx = _num_columns;
1284
0
        } else if (UNLIKELY(column->name() == VERSION_COL)) {
1285
0
            _version_col_idx = _num_columns;
1286
0
        } else if (UNLIKELY(column->name() == SKIP_BITMAP_COL)) {
1287
0
            _skip_bitmap_col_idx = _num_columns;
1288
0
        }
1289
0
        _cols.emplace_back(std::make_shared<TabletColumn>(*column));
1290
0
        _field_name_to_index.emplace(StringRef(_cols.back()->name()), _num_columns);
1291
0
        _field_uniqueid_to_index[_cols.back()->unique_id()] = _num_columns;
1292
0
        _num_columns++;
1293
0
    }
1294
1295
0
    for (const auto& i : index->indexes) {
1296
0
        size_t index_pos = _indexes.size();
1297
0
        _indexes.emplace_back(std::make_shared<TabletIndex>(*i));
1298
0
        for (int32_t col_uid : _indexes.back()->col_unique_ids()) {
1299
0
            if (auto field_pattern = _indexes.back()->field_pattern(); !field_pattern.empty()) {
1300
0
                auto& pattern_to_index_map = _index_by_unique_id_with_pattern[col_uid];
1301
0
                pattern_to_index_map[field_pattern].emplace_back(_indexes.back());
1302
0
            } else {
1303
0
                IndexKey key = std::make_tuple(_indexes.back()->index_type(), col_uid,
1304
0
                                               _indexes.back()->get_index_suffix());
1305
0
                _col_id_suffix_to_index[key].push_back(index_pos);
1306
0
            }
1307
0
        }
1308
0
    }
1309
1310
0
    if (has_bf_columns) {
1311
0
        _has_bf_fpp = true;
1312
0
        _bf_fpp = ori_tablet_schema.bloom_filter_fpp();
1313
0
    } else {
1314
0
        _has_bf_fpp = false;
1315
0
        _bf_fpp = BLOOM_FILTER_DEFAULT_FPP;
1316
0
    }
1317
0
}
1318
1319
149
void TabletSchema::merge_dropped_columns(const TabletSchema& src_schema) {
1320
    // If they are the same tablet schema object, then just return
1321
149
    if (this == &src_schema) {
1322
0
        return;
1323
0
    }
1324
2.90k
    for (const auto& src_col : src_schema.columns()) {
1325
2.90k
        if (_field_uniqueid_to_index.find(src_col->unique_id()) == _field_uniqueid_to_index.end()) {
1326
0
            CHECK(!src_col->is_key())
1327
0
                    << src_col->name() << " is key column, should not be dropped.";
1328
0
            ColumnPB src_col_pb;
1329
            // There are some pointer in tablet column, not sure the reference relation, so
1330
            // that deep copy it.
1331
0
            src_col->to_schema_pb(&src_col_pb);
1332
0
            TabletColumn new_col(src_col_pb);
1333
0
            append_column(new_col, TabletSchema::ColumnType::DROPPED);
1334
0
        }
1335
2.90k
    }
1336
149
}
1337
1338
0
TabletSchemaSPtr TabletSchema::copy_without_variant_extracted_columns() {
1339
0
    TabletSchemaSPtr copy = std::make_shared<TabletSchema>();
1340
0
    copy->shawdow_copy_without_columns(*this);
1341
0
    for (auto& col : this->columns()) {
1342
0
        if (col->is_extracted_column()) {
1343
0
            continue;
1344
0
        }
1345
0
        copy->append_column(*col);
1346
0
    }
1347
0
    return copy;
1348
0
}
1349
1350
// Dropped column is in _field_uniqueid_to_index but not in _field_name_to_index
1351
// Could refer to append_column method
1352
6.30k
bool TabletSchema::is_dropped_column(const TabletColumn& col) const {
1353
6.30k
    CHECK(_field_uniqueid_to_index.find(col.unique_id()) != _field_uniqueid_to_index.end())
1354
0
            << "could not find col with unique id = " << col.unique_id()
1355
0
            << " and name = " << col.name() << " table_id=" << _table_id;
1356
6.30k
    auto it = _field_name_to_index.find(StringRef {col.name()});
1357
6.30k
    return it == _field_name_to_index.end() || _cols[it->second]->unique_id() != col.unique_id();
1358
6.30k
}
1359
1360
0
void TabletSchema::copy_extracted_columns(const TabletSchema& src_schema) {
1361
0
    std::unordered_set<int32_t> variant_columns;
1362
0
    for (const auto& col : columns()) {
1363
0
        if (col->is_variant_type()) {
1364
0
            variant_columns.insert(col->unique_id());
1365
0
        }
1366
0
    }
1367
0
    for (const TabletColumnPtr& col : src_schema.columns()) {
1368
0
        if (col->is_extracted_column() && variant_columns.contains(col->parent_unique_id())) {
1369
0
            ColumnPB col_pb;
1370
0
            col->to_schema_pb(&col_pb);
1371
0
            TabletColumn new_col(col_pb);
1372
0
            append_column(new_col, ColumnType::VARIANT);
1373
0
        }
1374
0
    }
1375
0
}
1376
1377
0
void TabletSchema::reserve_extracted_columns() {
1378
0
    for (auto it = _cols.begin(); it != _cols.end();) {
1379
0
        if (!(*it)->is_extracted_column()) {
1380
0
            it = _cols.erase(it);
1381
0
        } else {
1382
0
            ++it;
1383
0
        }
1384
0
    }
1385
0
}
1386
1387
5.52k
void TabletSchema::to_schema_pb(TabletSchemaPB* tablet_schema_pb) const {
1388
5.52k
    for (const auto& i : _cluster_key_uids) {
1389
30
        tablet_schema_pb->add_cluster_key_uids(i);
1390
30
    }
1391
5.52k
    tablet_schema_pb->set_keys_type(_keys_type);
1392
31.6k
    for (const auto& col : _cols) {
1393
31.6k
        ColumnPB* column = tablet_schema_pb->add_column();
1394
31.6k
        col->to_schema_pb(column);
1395
31.6k
    }
1396
11.0k
    for (const auto& index : _indexes) {
1397
11.0k
        auto* index_pb = tablet_schema_pb->add_index();
1398
11.0k
        index->to_schema_pb(index_pb);
1399
11.0k
    }
1400
5.52k
    tablet_schema_pb->set_num_short_key_columns(cast_set<int32_t>(_num_short_key_columns));
1401
5.52k
    tablet_schema_pb->set_num_rows_per_row_block(cast_set<int32_t>(_num_rows_per_row_block));
1402
5.52k
    tablet_schema_pb->set_compress_kind(_compress_kind);
1403
5.52k
    if (_has_bf_fpp) {
1404
4
        tablet_schema_pb->set_bf_fpp(_bf_fpp);
1405
4
    }
1406
5.52k
    tablet_schema_pb->set_next_column_unique_id(cast_set<uint32_t>(_next_column_unique_id));
1407
5.52k
    tablet_schema_pb->set_is_in_memory(_is_in_memory);
1408
5.52k
    tablet_schema_pb->set_disable_auto_compaction(_disable_auto_compaction);
1409
5.52k
    tablet_schema_pb->set_enable_single_replica_compaction(_enable_single_replica_compaction);
1410
5.52k
    tablet_schema_pb->set_store_row_column(_store_row_column);
1411
5.52k
    tablet_schema_pb->set_skip_write_index_on_load(_skip_write_index_on_load);
1412
5.52k
    tablet_schema_pb->set_delete_sign_idx(_delete_sign_idx);
1413
5.52k
    tablet_schema_pb->set_sequence_col_idx(_sequence_col_idx);
1414
5.52k
    tablet_schema_pb->set_sort_type(_sort_type);
1415
5.52k
    tablet_schema_pb->set_sort_col_num(cast_set<int32_t>(_sort_col_num));
1416
5.52k
    tablet_schema_pb->set_schema_version(_schema_version);
1417
5.52k
    tablet_schema_pb->set_compression_type(_compression_type);
1418
5.52k
    tablet_schema_pb->set_row_store_page_size(_row_store_page_size);
1419
5.52k
    tablet_schema_pb->set_storage_page_size(_storage_page_size);
1420
5.52k
    tablet_schema_pb->set_storage_dict_page_size(_storage_dict_page_size);
1421
5.52k
    tablet_schema_pb->set_version_col_idx(_version_col_idx);
1422
5.52k
    tablet_schema_pb->set_skip_bitmap_col_idx(_skip_bitmap_col_idx);
1423
5.52k
    tablet_schema_pb->set_inverted_index_storage_format(_inverted_index_storage_format);
1424
5.52k
    tablet_schema_pb->mutable_row_store_column_unique_ids()->Assign(
1425
5.52k
            _row_store_column_unique_ids.begin(), _row_store_column_unique_ids.end());
1426
5.52k
    tablet_schema_pb->set_enable_variant_flatten_nested(_enable_variant_flatten_nested);
1427
5.52k
}
1428
1429
0
size_t TabletSchema::row_size() const {
1430
0
    size_t size = 0;
1431
0
    for (const auto& column : _cols) {
1432
0
        size += column->length();
1433
0
    }
1434
0
    size += (_num_columns + 7) / 8;
1435
1436
0
    return size;
1437
0
}
1438
1439
1.24k
int32_t TabletSchema::field_index(const std::string& field_name) const {
1440
1.24k
    const auto& found = _field_name_to_index.find(StringRef(field_name));
1441
1.24k
    return (found == _field_name_to_index.end()) ? -1 : found->second;
1442
1.24k
}
1443
1444
0
int32_t TabletSchema::field_index(const vectorized::PathInData& path) const {
1445
0
    const auto& found = _field_path_to_index.find(vectorized::PathInDataRef(&path));
1446
0
    return (found == _field_path_to_index.end()) ? -1 : found->second;
1447
0
}
1448
1449
179
int32_t TabletSchema::field_index(int32_t col_unique_id) const {
1450
179
    const auto& found = _field_uniqueid_to_index.find(col_unique_id);
1451
179
    return (found == _field_uniqueid_to_index.end()) ? -1 : found->second;
1452
179
}
1453
1454
27.2k
const std::vector<TabletColumnPtr>& TabletSchema::columns() const {
1455
27.2k
    return _cols;
1456
27.2k
}
1457
1458
114k
const TabletColumn& TabletSchema::column(size_t ordinal) const {
1459
114k
    DCHECK(ordinal < _num_columns) << "ordinal:" << ordinal << ", _num_columns:" << _num_columns;
1460
114k
    return *_cols[ordinal];
1461
114k
}
1462
1463
4.47k
const TabletColumn& TabletSchema::column_by_uid(int32_t col_unique_id) const {
1464
4.47k
    return *_cols.at(_field_uniqueid_to_index.at(col_unique_id));
1465
4.47k
}
1466
1467
1
TabletColumn& TabletSchema::mutable_column_by_uid(int32_t col_unique_id) {
1468
1
    return *_cols.at(_field_uniqueid_to_index.at(col_unique_id));
1469
1
}
1470
1471
18
TabletColumn& TabletSchema::mutable_column(size_t ordinal) {
1472
18
    return *_cols.at(ordinal);
1473
18
}
1474
1475
1
void TabletSchema::update_indexes_from_thrift(const std::vector<doris::TOlapTableIndex>& tindexes) {
1476
1
    std::vector<TabletIndexPtr> indexes;
1477
2
    for (const auto& tindex : tindexes) {
1478
2
        TabletIndex index;
1479
2
        index.init_from_thrift(tindex, *this);
1480
2
        indexes.emplace_back(std::make_shared<TabletIndex>(std::move(index)));
1481
2
    }
1482
1
    _indexes = std::move(indexes);
1483
1
    _col_id_suffix_to_index.clear();
1484
1
    _index_by_unique_id_with_pattern.clear();
1485
1
    size_t index_pos = 0;
1486
2
    for (auto& index : _indexes) {
1487
2
        for (int32_t col_uid : index->col_unique_ids()) {
1488
2
            if (auto field_pattern = index->field_pattern(); !field_pattern.empty()) {
1489
0
                auto& pattern_to_index_map = _index_by_unique_id_with_pattern[col_uid];
1490
0
                pattern_to_index_map[field_pattern].emplace_back(index);
1491
2
            } else {
1492
2
                IndexKey key =
1493
2
                        std::make_tuple(index->index_type(), col_uid, index->get_index_suffix());
1494
2
                _col_id_suffix_to_index[key].push_back(index_pos);
1495
2
            }
1496
2
        }
1497
2
        index_pos++;
1498
2
    }
1499
1
}
1500
1501
0
bool TabletSchema::exist_column(const std::string& field_name) const {
1502
0
    return _field_name_to_index.contains(StringRef {field_name});
1503
0
}
1504
1505
39.1k
bool TabletSchema::has_column_unique_id(int32_t col_unique_id) const {
1506
39.1k
    return _field_uniqueid_to_index.contains(col_unique_id);
1507
39.1k
}
1508
1509
4.04k
Status TabletSchema::have_column(const std::string& field_name) const {
1510
4.04k
    if (!_field_name_to_index.contains(StringRef(field_name))) {
1511
4.04k
        return Status::Error<ErrorCode::INTERNAL_ERROR>(
1512
4.04k
                "Not found field_name, field_name:{}, schema:{}", field_name,
1513
4.04k
                get_all_field_names());
1514
4.04k
    }
1515
0
    return Status::OK();
1516
4.04k
}
1517
1518
167
Result<const TabletColumn*> TabletSchema::column(const std::string& field_name) const {
1519
167
    auto it = _field_name_to_index.find(StringRef {field_name});
1520
167
    if (it == _field_name_to_index.end()) {
1521
0
        DCHECK(false) << "field_name=" << field_name << ", table_id=" << _table_id
1522
0
                      << ", field_name_to_index=" << get_all_field_names();
1523
0
        return ResultError(
1524
0
                Status::InternalError("column not found, name={}, table_id={}, schema_version={}",
1525
0
                                      field_name, _table_id, _schema_version));
1526
0
    }
1527
167
    return _cols[it->second].get();
1528
167
}
1529
1530
void TabletSchema::update_tablet_columns(const TabletSchema& tablet_schema,
1531
0
                                         const std::vector<TColumn>& t_columns) {
1532
0
    copy_from(tablet_schema);
1533
0
    if (!t_columns.empty() && t_columns[0].col_unique_id >= 0) {
1534
0
        clear_columns();
1535
0
        for (const auto& column : t_columns) {
1536
0
            append_column(TabletColumn(column));
1537
0
        }
1538
0
    }
1539
0
}
1540
1541
55
bool TabletSchema::has_inverted_index_with_index_id(int64_t index_id) const {
1542
72
    for (size_t i = 0; i < _indexes.size(); i++) {
1543
37
        if (_indexes[i]->index_type() == IndexType::INVERTED &&
1544
37
            _indexes[i]->index_id() == index_id) {
1545
20
            return true;
1546
20
        }
1547
37
    }
1548
35
    return false;
1549
55
}
1550
1551
std::vector<const TabletIndex*> TabletSchema::inverted_indexs(
1552
30.6k
        int32_t col_unique_id, const std::string& suffix_path) const {
1553
30.6k
    std::vector<const TabletIndex*> result;
1554
30.6k
    const std::string escaped_suffix = escape_for_path_name(suffix_path);
1555
30.6k
    auto it = _col_id_suffix_to_index.find(
1556
30.6k
            std::make_tuple(IndexType::INVERTED, col_unique_id, escaped_suffix));
1557
30.6k
    if (it != _col_id_suffix_to_index.end()) {
1558
7.84k
        for (size_t pos : it->second) {
1559
7.84k
            if (pos < _indexes.size()) {
1560
7.84k
                result.push_back(_indexes[pos].get());
1561
7.84k
            }
1562
7.84k
        }
1563
7.81k
    }
1564
30.6k
    return result;
1565
30.6k
}
1566
1567
std::vector<TabletIndexPtr> TabletSchema::inverted_index_by_field_pattern(
1568
56
        int32_t col_unique_id, const std::string& field_pattern) const {
1569
56
    auto id_to_pattern_map = _index_by_unique_id_with_pattern.find(col_unique_id);
1570
56
    if (id_to_pattern_map == _index_by_unique_id_with_pattern.end()) {
1571
47
        return {};
1572
47
    }
1573
9
    auto pattern_to_index_map = id_to_pattern_map->second.find(field_pattern);
1574
9
    if (pattern_to_index_map == id_to_pattern_map->second.end()) {
1575
4
        return {};
1576
4
    }
1577
5
    return pattern_to_index_map->second;
1578
9
}
1579
1580
26.8k
std::vector<const TabletIndex*> TabletSchema::inverted_indexs(const TabletColumn& col) const {
1581
    // Some columns(Float, Double, JSONB ...) from the variant do not support inverted index
1582
26.8k
    if (!segment_v2::IndexColumnWriter::check_support_inverted_index(col)) {
1583
334
        return {};
1584
334
    }
1585
1586
    // TODO use more efficient impl
1587
    // Use parent id if unique not assigned, this could happend when accessing subcolumns of variants
1588
26.5k
    int32_t col_unique_id = col.is_extracted_column() ? col.parent_unique_id() : col.unique_id();
1589
26.5k
    std::vector<const TabletIndex*> result;
1590
26.5k
    if (result = inverted_indexs(col_unique_id, escape_for_path_name(col.suffix_path()));
1591
26.5k
        !result.empty()) {
1592
5.19k
        return result;
1593
5.19k
    }
1594
    // variant's typed column has it's own index
1595
21.3k
    else if (col.is_extracted_column() && col.path_info_ptr()->get_is_typed()) {
1596
2
        std::string relative_path = col.path_info_ptr()->copy_pop_front().get_path();
1597
2
        if (_path_set_info_map.find(col_unique_id) == _path_set_info_map.end()) {
1598
0
            return result;
1599
0
        }
1600
2
        const auto& path_set_info = _path_set_info_map.at(col_unique_id);
1601
2
        if (path_set_info.typed_path_set.find(relative_path) ==
1602
2
            path_set_info.typed_path_set.end()) {
1603
0
            return result;
1604
0
        }
1605
2
        for (const auto& index : path_set_info.typed_path_set.at(relative_path).indexes) {
1606
2
            result.push_back(index.get());
1607
2
        }
1608
2
        return result;
1609
2
    }
1610
    // variant's subcolumns has it's own index
1611
21.3k
    else if (col.is_extracted_column()) {
1612
3
        std::string relative_path = col.path_info_ptr()->copy_pop_front().get_path();
1613
3
        if (_path_set_info_map.find(col_unique_id) == _path_set_info_map.end()) {
1614
1
            return result;
1615
1
        }
1616
2
        const auto& path_set_info = _path_set_info_map.at(col_unique_id);
1617
2
        if (path_set_info.subcolumn_indexes.find(relative_path) ==
1618
2
            path_set_info.subcolumn_indexes.end()) {
1619
1
            return result;
1620
1
        }
1621
1
        for (const auto& index : path_set_info.subcolumn_indexes.at(relative_path)) {
1622
1
            result.push_back(index.get());
1623
1
        }
1624
1
    }
1625
21.3k
    return result;
1626
26.5k
}
1627
1628
const TabletIndex* TabletSchema::ann_index(int32_t col_unique_id,
1629
10.1k
                                           const std::string& suffix_path) const {
1630
11.4k
    for (size_t i = 0; i < _indexes.size(); i++) {
1631
1.33k
        if (_indexes[i]->index_type() == IndexType::ANN) {
1632
0
            for (int32_t id : _indexes[i]->col_unique_ids()) {
1633
0
                if (id == col_unique_id &&
1634
0
                    _indexes[i]->get_index_suffix() == escape_for_path_name(suffix_path)) {
1635
0
                    return _indexes[i].get();
1636
0
                }
1637
0
            }
1638
0
        }
1639
1.33k
    }
1640
10.1k
    return nullptr;
1641
10.1k
}
1642
1643
13.8k
const TabletIndex* TabletSchema::ann_index(const TabletColumn& col) const {
1644
    // Some columns(Float, Double, JSONB ...) from the variant do not support inverted index
1645
13.8k
    if (!segment_v2::IndexColumnWriter::check_support_ann_index(col)) {
1646
13.8k
        return nullptr;
1647
13.8k
    }
1648
    // TODO use more efficient impl
1649
    // Use parent id if unique not assigned, this could happend when accessing subcolumns of variants
1650
1
    int32_t col_unique_id = col.is_extracted_column() ? col.parent_unique_id() : col.unique_id();
1651
1
    return ann_index(col_unique_id, escape_for_path_name(col.suffix_path()));
1652
13.8k
}
1653
1654
0
bool TabletSchema::has_ngram_bf_index(int32_t col_unique_id) const {
1655
0
    IndexKey index_key(IndexType::NGRAM_BF, col_unique_id, "");
1656
0
    auto it = _col_id_suffix_to_index.find(index_key);
1657
0
    return it != _col_id_suffix_to_index.end();
1658
0
}
1659
1660
13.8k
const TabletIndex* TabletSchema::get_ngram_bf_index(int32_t col_unique_id) const {
1661
    // Get the ngram bf index for the given column unique id
1662
13.8k
    IndexKey index_key(IndexType::NGRAM_BF, col_unique_id, "");
1663
13.8k
    auto it = _col_id_suffix_to_index.find(index_key);
1664
13.8k
    if (it != _col_id_suffix_to_index.end()) {
1665
1
        if (!it->second.empty() && it->second[0] < _indexes.size()) {
1666
1
            return _indexes[it->second[0]].get();
1667
1
        }
1668
1
    }
1669
13.8k
    return nullptr;
1670
13.8k
}
1671
1672
vectorized::Block TabletSchema::create_block(
1673
        const std::vector<uint32_t>& return_columns,
1674
723
        const std::unordered_set<uint32_t>* tablet_columns_need_convert_null) const {
1675
723
    vectorized::Block block;
1676
2.85k
    for (int i = 0; i < return_columns.size(); ++i) {
1677
2.13k
        const ColumnId cid = return_columns[i];
1678
2.13k
        const auto& col = *_cols[cid];
1679
2.13k
        bool is_nullable = (tablet_columns_need_convert_null != nullptr &&
1680
2.13k
                            tablet_columns_need_convert_null->find(cid) !=
1681
0
                                    tablet_columns_need_convert_null->end());
1682
2.13k
        auto data_type = vectorized::DataTypeFactory::instance().create_data_type(col, is_nullable);
1683
2.13k
        if (_vir_col_idx_to_unique_id.contains(cid)) {
1684
0
            block.insert({vectorized::ColumnNothing::create(0), data_type, col.name()});
1685
0
            VLOG_DEBUG << fmt::format(
1686
0
                    "Create block from tablet schema, column cid {} is virtual column, col_name: "
1687
0
                    "{}, col_unique_id: {}, type {}",
1688
0
                    cid, col.name(), col.unique_id(), data_type->get_name());
1689
2.13k
        } else {
1690
2.13k
            block.insert({data_type->create_column(), data_type, col.name()});
1691
2.13k
        }
1692
2.13k
    }
1693
723
    return block;
1694
723
}
1695
1696
1.99k
vectorized::Block TabletSchema::create_block(bool ignore_dropped_col) const {
1697
1.99k
    vectorized::Block block;
1698
6.30k
    for (const auto& col : _cols) {
1699
6.30k
        if (ignore_dropped_col && is_dropped_column(*col)) {
1700
0
            continue;
1701
0
        }
1702
6.30k
        auto data_type = vectorized::DataTypeFactory::instance().create_data_type(*col);
1703
6.30k
        block.insert({data_type->create_column(), data_type, col->name()});
1704
6.30k
    }
1705
1.99k
    return block;
1706
1.99k
}
1707
1708
0
vectorized::Block TabletSchema::create_block_by_cids(const std::vector<uint32_t>& cids) const {
1709
0
    vectorized::Block block;
1710
0
    for (const auto& cid : cids) {
1711
0
        const auto& col = *_cols[cid];
1712
0
        auto data_type = vectorized::DataTypeFactory::instance().create_data_type(col);
1713
0
        block.insert({data_type->create_column(), data_type, col.name()});
1714
0
    }
1715
0
    return block;
1716
0
}
1717
1718
0
bool operator==(const TabletColumn& a, const TabletColumn& b) {
1719
0
    if (a._unique_id != b._unique_id) return false;
1720
0
    if (a._col_name != b._col_name) return false;
1721
0
    if (a._type != b._type) return false;
1722
0
    if (a._is_key != b._is_key) return false;
1723
0
    if (a._aggregation != b._aggregation) return false;
1724
0
    if (a._is_nullable != b._is_nullable) return false;
1725
0
    if (a._has_default_value != b._has_default_value) return false;
1726
0
    if (a._has_default_value) {
1727
0
        if (a._default_value != b._default_value) return false;
1728
0
    }
1729
0
    if (a._is_decimal != b._is_decimal) return false;
1730
0
    if (a._is_decimal) {
1731
0
        if (a._precision != b._precision) return false;
1732
0
        if (a._frac != b._frac) return false;
1733
0
    }
1734
0
    if (a._length != b._length) return false;
1735
0
    if (a._index_length != b._index_length) return false;
1736
0
    if (a._is_bf_column != b._is_bf_column) return false;
1737
0
    if (a._has_bitmap_index != b._has_bitmap_index) return false;
1738
0
    if (a._column_path == nullptr && a._column_path != nullptr) return false;
1739
0
    if (b._column_path == nullptr && a._column_path != nullptr) return false;
1740
0
    if (b._column_path != nullptr && a._column_path != nullptr &&
1741
0
        *a._column_path != *b._column_path)
1742
0
        return false;
1743
0
    return true;
1744
0
}
1745
1746
0
bool operator!=(const TabletColumn& a, const TabletColumn& b) {
1747
0
    return !(a == b);
1748
0
}
1749
1750
3
bool operator==(const TabletSchema& a, const TabletSchema& b) {
1751
3
    if (a._keys_type != b._keys_type) return false;
1752
3
    if (a._cols.size() != b._cols.size()) return false;
1753
3
    for (int i = 0; i < a._cols.size(); ++i) {
1754
0
        if (*a._cols[i] != *b._cols[i]) return false;
1755
0
    }
1756
3
    if (a._num_columns != b._num_columns) return false;
1757
3
    if (a._num_key_columns != b._num_key_columns) return false;
1758
3
    if (a._num_null_columns != b._num_null_columns) return false;
1759
3
    if (a._num_short_key_columns != b._num_short_key_columns) return false;
1760
3
    if (a._num_rows_per_row_block != b._num_rows_per_row_block) return false;
1761
3
    if (a._compress_kind != b._compress_kind) return false;
1762
3
    if (a._next_column_unique_id != b._next_column_unique_id) return false;
1763
3
    if (a._has_bf_fpp != b._has_bf_fpp) return false;
1764
3
    if (a._has_bf_fpp) {
1765
0
        if (std::abs(a._bf_fpp - b._bf_fpp) > 1e-6) return false;
1766
0
    }
1767
3
    if (a._is_in_memory != b._is_in_memory) return false;
1768
3
    if (a._delete_sign_idx != b._delete_sign_idx) return false;
1769
3
    if (a._disable_auto_compaction != b._disable_auto_compaction) return false;
1770
3
    if (a._enable_single_replica_compaction != b._enable_single_replica_compaction) return false;
1771
3
    if (a._store_row_column != b._store_row_column) return false;
1772
3
    if (a._row_store_page_size != b._row_store_page_size) return false;
1773
3
    if (a._storage_page_size != b._storage_page_size) return false;
1774
3
    if (a._storage_dict_page_size != b._storage_dict_page_size) return false;
1775
3
    if (a._skip_write_index_on_load != b._skip_write_index_on_load) return false;
1776
3
    if (a._enable_variant_flatten_nested != b._enable_variant_flatten_nested) return false;
1777
3
    return true;
1778
3
}
1779
1780
3
bool operator!=(const TabletSchema& a, const TabletSchema& b) {
1781
3
    return !(a == b);
1782
3
}
1783
#include "common/compile_check_end.h"
1784
} // namespace doris