Coverage Report

Created: 2025-09-15 20:29

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