Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Jan 4, 2024
1 parent 54a149b commit 378d5e3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
7 changes: 2 additions & 5 deletions be/src/vec/exprs/vcase_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ void VCaseExpr::close(VExprContext* context, FunctionContext::FunctionStateScope
}

Status VCaseExpr::execute(VExprContext* context, Block* block, int* result_column_id) {
if ((_constant_col != nullptr) && is_constant()) { // const have execute in open function
*result_column_id = block->columns();
auto column = ColumnConst::create(_constant_col->column_ptr, block->rows());
block->insert({std::move(column), _data_type, _expr_name});
return Status::OK();
if (is_const_and_have_executed()) { // const have execute in open function
return get_result_from_const(block, _expr_name, result_column_id);
}
ColumnNumbers arguments(_children.size());
for (int i = 0; i < _children.size(); i++) {
Expand Down
7 changes: 2 additions & 5 deletions be/src/vec/exprs/vectorized_fn_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,8 @@ void VectorizedFnCall::close(VExprContext* context, FunctionContext::FunctionSta

Status VectorizedFnCall::execute(VExprContext* context, vectorized::Block* block,
int* result_column_id) {
if ((_constant_col != nullptr) && is_constant()) { // const have execute in open function
*result_column_id = block->columns();
auto column = ColumnConst::create(_constant_col->column_ptr, block->rows());
block->insert({std::move(column), _data_type, _expr_name});
return Status::OK();
if (is_const_and_have_executed()) { // const have execute in open function
return get_result_from_const(block, _expr_name, result_column_id);
}

// TODO: not execute const expr again, but use the const column in function context
Expand Down
8 changes: 8 additions & 0 deletions be/src/vec/exprs/vexpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,4 +554,12 @@ Status VExpr::check_constant(const Block& block, ColumnNumbers arguments) const
return Status::OK();
}

Status VExpr::get_result_from_const(vectorized::Block* block, const std::string& expr_name,
int* result_column_id) {
*result_column_id = block->columns();
auto column = ColumnConst::create(_constant_col->column_ptr, block->rows());
block->insert({std::move(column), _data_type, expr_name});
return Status::OK();
}

} // namespace doris::vectorized
5 changes: 5 additions & 0 deletions be/src/vec/exprs/vexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ class VExpr {
return res;
}

bool is_const_and_have_executed() { return (is_constant() && (_constant_col != nullptr)); }

Status get_result_from_const(vectorized::Block* block, const std::string& expr_name,
int* result_column_id);

Status check_constant(const Block& block, ColumnNumbers arguments) const;

/// Helper function that calls ctx->register(), sets fn_context_index_, and returns the
Expand Down
7 changes: 2 additions & 5 deletions be/src/vec/exprs/vin_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ void VInPredicate::close(VExprContext* context, FunctionContext::FunctionStateSc
}

Status VInPredicate::execute(VExprContext* context, Block* block, int* result_column_id) {
if ((_constant_col != nullptr) && is_constant()) { // const have execute in open function
*result_column_id = block->columns();
auto column = ColumnConst::create(_constant_col->column_ptr, block->rows());
block->insert({std::move(column), _data_type, _expr_name});
return Status::OK();
if (is_const_and_have_executed()) { // const have execute in open function
return get_result_from_const(block, _expr_name, result_column_id);
}
// TODO: not execute const expr again, but use the const column in function context
doris::vectorized::ColumnNumbers arguments(_children.size());
Expand Down

0 comments on commit 378d5e3

Please sign in to comment.