Coverage Report

Created: 2026-06-04 11:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/partition_column_filler.h
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
#pragma once
19
20
#include <glog/logging.h>
21
22
#include <string>
23
24
#include "common/status.h"
25
#include "core/assert_cast.h"
26
#include "core/column/column_nullable.h"
27
#include "core/data_type_serde/data_type_serde.h"
28
#include "runtime/descriptors.h"
29
#include "util/slice.h"
30
31
namespace doris {
32
33
inline Status fill_partition_column_from_path_value(
34
        IColumn& column, const SlotDescriptor& slot_desc, const std::string& value, size_t rows,
35
58
        bool explicit_null_marker, DataTypeSerDe::FormatOptions text_format_options = {}) {
36
58
    auto data_type = slot_desc.get_data_type_ptr();
37
58
    auto text_serde = data_type->get_serde();
38
58
    uint64_t num_deserialized = 0;
39
40
58
    if (explicit_null_marker) {
41
0
        DCHECK(data_type->is_nullable());
42
0
        column.insert_many_defaults(rows);
43
0
        return Status::OK();
44
0
    }
45
46
58
    IColumn* value_column = &column;
47
58
    DataTypeSerDeSPtr value_serde = text_serde;
48
58
    ColumnNullable* nullable_column = nullptr;
49
58
    if (data_type->is_nullable()) {
50
2
        nullable_column = assert_cast<ColumnNullable*>(&column);
51
2
        value_column = &nullable_column->get_nested_column();
52
2
        value_serde = text_serde->get_nested_serdes()[0];
53
2
    }
54
55
58
    const size_t old_size = value_column->size();
56
58
    Slice slice(value.data(), value.size());
57
58
    Status status = value_serde->deserialize_column_from_fixed_json(
58
58
            *value_column, slice, rows, &num_deserialized, text_format_options);
59
58
    if (!status.ok()) {
60
1
        value_column->resize(old_size);
61
1
        return Status::InternalError("Failed to fill partition column: {}={}", slot_desc.col_name(),
62
1
                                     value);
63
1
    }
64
57
    if (num_deserialized != rows) {
65
0
        value_column->resize(old_size);
66
0
        return Status::InternalError(
67
0
                "Failed to fill partition column: {}={}. Expected rows: {}, actual: {}",
68
0
                slot_desc.col_name(), value, rows, num_deserialized);
69
0
    }
70
57
    if (nullable_column != nullptr) {
71
2
        nullable_column->get_null_map_column().insert_many_vals(0, rows);
72
2
    }
73
57
    return Status::OK();
74
57
}
75
76
} // namespace doris