Coverage Report

Created: 2026-06-25 05:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/vslot_ref.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
#include <string>
20
21
#include "common/object_pool.h"
22
#include "common/status.h"
23
#include "exprs/vexpr.h"
24
25
namespace doris {
26
class SlotDescriptor;
27
class RowDescriptor;
28
class RuntimeState;
29
class TExprNode;
30
31
class Block;
32
class VExprContext;
33
34
class VSlotRef : public VExpr {
35
    ENABLE_FACTORY_CREATOR(VSlotRef);
36
37
public:
38
    VSlotRef(const TExprNode& node);
39
    VSlotRef(const SlotDescriptor* desc);
40
    VSlotRef(int slot_id, int column_id, int column_uniq_id, const DataTypePtr& type,
41
             std::string column_name);
42
#ifdef BE_TEST
43
    VSlotRef() = default;
44
    void set_slot_id(int slot_id) { _slot_id = slot_id; }
45
#endif
46
960
    void set_column_id(int column_id) { _column_id = column_id; }
47
    Status prepare(RuntimeState* state, const RowDescriptor& desc, VExprContext* context) override;
48
    Status open(RuntimeState* state, VExprContext* context,
49
                FunctionContext::FunctionStateScope scope) override;
50
    Status execute(VExprContext* context, Block* block, int* result_column_id) const override;
51
    Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector,
52
                               size_t count, ColumnPtr& result_column) const override;
53
    DataTypePtr execute_type(const Block* block) const override;
54
55
    const std::string& expr_name() const override;
56
    std::string expr_label() override;
57
    std::string debug_string() const override;
58
5.73M
    bool is_constant() const override { return false; }
59
60
143k
    int column_id() const { return _column_id; }
61
62
845k
    MOCK_FUNCTION int slot_id() const { return _slot_id; }
63
    int column_uniq_id() const { return _column_uniq_id; }
64
65
    bool equals(const VExpr& other) override;
66
67
43.0k
    size_t estimate_memory(const size_t rows) override { return 0; }
68
69
3.37k
    void collect_slot_column_ids(std::set<int>& column_ids) const override {
70
3.37k
        column_ids.insert(_column_id);
71
3.37k
    }
72
73
102
    virtual const std::string& column_name() const { return *_column_name; }
74
75
    uint64_t get_digest(uint64_t seed) const override;
76
77
651k
    double execute_cost() const override { return 0.0; }
78
    Status clone_node(VExprSPtr* cloned_expr) const override;
79
80
protected:
81
    VSlotRef(int slot_id, int column_id, int column_uniq_id)
82
0
            : _slot_id(slot_id), _column_id(column_id), _column_uniq_id(column_uniq_id) {
83
0
        _node_type = TExprNodeType::SLOT_REF;
84
0
    }
85
86
private:
87
    int _slot_id;
88
    int _column_id;
89
    int _column_uniq_id = -1;
90
    std::string _owned_column_name;
91
    const std::string* _column_name = nullptr;
92
    const std::string _column_label;
93
};
94
} // namespace doris