Coverage Report

Created: 2026-05-25 13:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/information_schema/schema_scanner_helper.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "information_schema/schema_scanner_helper.h"
19
20
#include "cctz/time_zone.h"
21
#include "core/block/block.h"
22
#include "core/column/column_nullable.h"
23
#include "core/data_type/data_type_factory.hpp"
24
#include "core/data_type/primitive_type.h"
25
#include "core/string_ref.h"
26
#include "runtime/exec_env.h"
27
#include "runtime/runtime_state.h"
28
#include "util/client_cache.h"
29
#include "util/thrift_rpc_helper.h"
30
31
namespace doris {
32
33
void SchemaScannerHelper::insert_string_value(int col_index, std::string_view str_val,
34
1
                                              Block* block) {
35
1
    MutableColumnPtr mutable_col_ptr =
36
1
            IColumn::mutate(std::move(block->get_by_position(col_index).column));
37
1
    auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get());
38
1
    IColumn* col_ptr = &nullable_column->get_nested_column();
39
1
    assert_cast<ColumnString*>(col_ptr)->insert_data(str_val.data(), str_val.size());
40
1
    nullable_column->push_false_to_nullmap(1);
41
1
    block->replace_by_position(col_index, std::move(mutable_col_ptr));
42
1
}
43
44
void SchemaScannerHelper::insert_datetime_value(int col_index, const std::vector<void*>& datas,
45
0
                                                Block* block) {
46
0
    MutableColumnPtr mutable_col_ptr =
47
0
            IColumn::mutate(std::move(block->get_by_position(col_index).column));
48
0
    auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get());
49
0
    IColumn* col_ptr = &nullable_column->get_nested_column();
50
0
    auto data = datas[0];
51
0
    assert_cast<ColumnDateTime*>(col_ptr)->insert_data(reinterpret_cast<char*>(data), 0);
52
0
    nullable_column->push_false_to_nullmap(1);
53
0
    block->replace_by_position(col_index, std::move(mutable_col_ptr));
54
0
}
55
56
void SchemaScannerHelper::insert_datetime_value(int col_index, int64_t timestamp,
57
0
                                                const cctz::time_zone& ctz, Block* block) {
58
0
    MutableColumnPtr mutable_col_ptr =
59
0
            IColumn::mutate(std::move(block->get_by_position(col_index).column));
60
0
    auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get());
61
0
    IColumn* col_ptr = &nullable_column->get_nested_column();
62
63
0
    std::vector<void*> datas(1);
64
0
    VecDateTimeValue src[1];
65
0
    src[0].from_unixtime(timestamp, ctz);
66
0
    datas[0] = src;
67
0
    auto data = datas[0];
68
0
    assert_cast<ColumnDateTime*>(col_ptr)->insert_data(reinterpret_cast<char*>(data), 0);
69
0
    nullable_column->push_false_to_nullmap(1);
70
0
    block->replace_by_position(col_index, std::move(mutable_col_ptr));
71
0
}
72
73
1
void SchemaScannerHelper::insert_bool_value(int col_index, bool bool_val, Block* block) {
74
1
    MutableColumnPtr mutable_col_ptr =
75
1
            IColumn::mutate(std::move(block->get_by_position(col_index).column));
76
1
    auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get());
77
1
    IColumn* col_ptr = &nullable_column->get_nested_column();
78
1
    assert_cast<ColumnBool*>(col_ptr)->insert_value(bool_val);
79
1
    nullable_column->push_false_to_nullmap(1);
80
1
    block->replace_by_position(col_index, std::move(mutable_col_ptr));
81
1
}
82
83
0
void SchemaScannerHelper::insert_int32_value(int col_index, int32_t int_val, Block* block) {
84
0
    MutableColumnPtr mutable_col_ptr =
85
0
            IColumn::mutate(std::move(block->get_by_position(col_index).column));
86
0
    auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get());
87
0
    IColumn* col_ptr = &nullable_column->get_nested_column();
88
0
    assert_cast<ColumnInt32*>(col_ptr)->insert_value(int_val);
89
0
    nullable_column->push_false_to_nullmap(1);
90
0
    block->replace_by_position(col_index, std::move(mutable_col_ptr));
91
0
}
92
93
2
void SchemaScannerHelper::insert_int64_value(int col_index, int64_t int_val, Block* block) {
94
2
    MutableColumnPtr mutable_col_ptr =
95
2
            IColumn::mutate(std::move(block->get_by_position(col_index).column));
96
2
    auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get());
97
2
    IColumn* col_ptr = &nullable_column->get_nested_column();
98
2
    assert_cast<ColumnInt64*>(col_ptr)->insert_value(int_val);
99
2
    nullable_column->push_false_to_nullmap(1);
100
2
    block->replace_by_position(col_index, std::move(mutable_col_ptr));
101
2
}
102
103
0
void SchemaScannerHelper::insert_double_value(int col_index, double double_val, Block* block) {
104
0
    MutableColumnPtr mutable_col_ptr =
105
0
            IColumn::mutate(std::move(block->get_by_position(col_index).column));
106
0
    auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get());
107
0
    IColumn* col_ptr = &nullable_column->get_nested_column();
108
0
    assert_cast<ColumnFloat64*>(col_ptr)->insert_value(double_val);
109
0
    nullable_column->push_false_to_nullmap(1);
110
0
    block->replace_by_position(col_index, std::move(mutable_col_ptr));
111
0
}
112
} // namespace doris