This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 46ccbebfb0b [improve](function) get result from constant_col when expr
is const (#29403)
46ccbebfb0b is described below
commit 46ccbebfb0be37f6922d7c44c079bfbb3842d7f6
Author: zhangstar333 <[email protected]>
AuthorDate: Fri Jan 5 11:26:17 2024 +0800
[improve](function) get result from constant_col when expr is const (#29403)
---
be/src/vec/exprs/vcase_expr.cpp | 3 +++
be/src/vec/exprs/vectorized_fn_call.cpp | 4 ++++
be/src/vec/exprs/vexpr.cpp | 8 ++++++++
be/src/vec/exprs/vexpr.h | 5 +++++
be/src/vec/exprs/vin_predicate.cpp | 3 +++
5 files changed, 23 insertions(+)
diff --git a/be/src/vec/exprs/vcase_expr.cpp b/be/src/vec/exprs/vcase_expr.cpp
index bd93cb8226c..e09d62bfb23 100644
--- a/be/src/vec/exprs/vcase_expr.cpp
+++ b/be/src/vec/exprs/vcase_expr.cpp
@@ -95,6 +95,9 @@ void VCaseExpr::close(VExprContext* context,
FunctionContext::FunctionStateScope
}
Status VCaseExpr::execute(VExprContext* context, Block* block, int*
result_column_id) {
+ 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++) {
int column_id = -1;
diff --git a/be/src/vec/exprs/vectorized_fn_call.cpp
b/be/src/vec/exprs/vectorized_fn_call.cpp
index 58083a486f6..48522b35500 100644
--- a/be/src/vec/exprs/vectorized_fn_call.cpp
+++ b/be/src/vec/exprs/vectorized_fn_call.cpp
@@ -138,6 +138,10 @@ void VectorizedFnCall::close(VExprContext* context,
FunctionContext::FunctionSta
Status VectorizedFnCall::execute(VExprContext* context, vectorized::Block*
block,
int* result_column_id) {
+ 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
vectorized::ColumnNumbers arguments(_children.size());
for (int i = 0; i < _children.size(); ++i) {
diff --git a/be/src/vec/exprs/vexpr.cpp b/be/src/vec/exprs/vexpr.cpp
index 3f06dbb7f54..7270126e563 100644
--- a/be/src/vec/exprs/vexpr.cpp
+++ b/be/src/vec/exprs/vexpr.cpp
@@ -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
diff --git a/be/src/vec/exprs/vexpr.h b/be/src/vec/exprs/vexpr.h
index 708b57ab638..b6a2b4ac6bd 100644
--- a/be/src/vec/exprs/vexpr.h
+++ b/be/src/vec/exprs/vexpr.h
@@ -220,6 +220,11 @@ protected:
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
diff --git a/be/src/vec/exprs/vin_predicate.cpp
b/be/src/vec/exprs/vin_predicate.cpp
index 55e999af477..9a25d3a2230 100644
--- a/be/src/vec/exprs/vin_predicate.cpp
+++ b/be/src/vec/exprs/vin_predicate.cpp
@@ -94,6 +94,9 @@ void VInPredicate::close(VExprContext* context,
FunctionContext::FunctionStateSc
}
Status VInPredicate::execute(VExprContext* context, Block* block, int*
result_column_id) {
+ 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());
for (int i = 0; i < _children.size(); ++i) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]