You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by zc...@apache.org on 2025/12/08 07:12:05 UTC
(doris) branch master updated: [chore](exec) BE constant folding no longer needs to construct a temporary block (#58710)
This is an automated email from the ASF dual-hosted git repository.
zclll 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 b8dba0fbf71 [chore](exec) BE constant folding no longer needs to construct a temporary block (#58710)
b8dba0fbf71 is described below
commit b8dba0fbf718bc9b72432cdf3e05db25ca6cf96c
Author: Mryange <ya...@selectdb.com>
AuthorDate: Mon Dec 8 15:11:57 2025 +0800
[chore](exec) BE constant folding no longer needs to construct a temporary block (#58710)
Also, this PR fixes a bug: previously BE constant folding did not pass
whether casts should be performed in strict mode.
```
W20251205 13:32:09.197405 512888 internal_service.cpp:1608] exec fold constant expr failed, errmsg=[INTERNAL_ERROR]ColumnWithTypeAndName check column type failed, column name: (CAST String(String) TO IPv4), type: IPv4, column: Const(Nullable(IPV4)) , error: [INTERNAL_ERROR]Column type Const(Nullable(IPV4)) is not compatible with data type IPv4 0# doris::Status doris::vectorized::IDataType::check_column_non_nested_type<doris::vectorized::ColumnVector<(doris::PrimitiveType)36> [...]
1# doris::vectorized::DataTypeNumberBase<(doris::PrimitiveType)36>::check_column(doris::vectorized::IColumn const&) const at /root/doris/be/src/vec/data_types/data_type_number_base.cpp:239
2# doris::vectorized::ColumnWithTypeAndName::check_type_and_column_match() const at /root/doris/be/src/vec/core/column_with_type_and_name.cpp:0
3# doris::vectorized::VExprContext::execute(doris::vectorized::Block*, int*) at /root/doris/be/src/vec/exprs/vexpr_context.cpp:0
4# doris::FoldConstantExecutor::fold_constant_vexpr(doris::TFoldConstantParams const&, doris::PConstantExprResult*) at /root/doris/be/src/common/status.h:0
5# std::_Function_handler<void (), doris::PInternalService::fold_constant_expr(google::protobuf::RpcController*, doris::PConstantExprRequest const*, doris::PConstantExprResult*, google::protobuf::Closure*)::$_0>::_M_invoke(std::_Any_data const&) at /root/doris/be/src/common/status.h:0
```
---
be/src/runtime/fold_constant_executor.cpp | 12 ++++--------
.../nereids/rules/expression/rules/FoldConstantRuleOnBE.java | 2 ++
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/be/src/runtime/fold_constant_executor.cpp b/be/src/runtime/fold_constant_executor.cpp
index 2887d39f45b..6ccf1bc9af5 100644
--- a/be/src/runtime/fold_constant_executor.cpp
+++ b/be/src/runtime/fold_constant_executor.cpp
@@ -95,21 +95,17 @@ Status FoldConstantExecutor::fold_constant_vexpr(const TFoldConstantParams& para
// prepare and open context
RETURN_IF_ERROR(_prepare_and_open(ctx.get()));
- vectorized::Block tmp_block;
- tmp_block.insert({vectorized::ColumnUInt8::create(1),
- std::make_shared<vectorized::DataTypeUInt8>(), ""});
- int result_column = -1;
+ vectorized::ColumnWithTypeAndName tmp_data;
// calc vexpr
- RETURN_IF_ERROR(ctx->execute(&tmp_block, &result_column));
- DCHECK(result_column != -1);
+ RETURN_IF_ERROR(ctx->execute_const_expr(tmp_data));
// covert to thrift type
const auto& res_type = ctx->root()->data_type();
TPrimitiveType::type t_type = doris::to_thrift(res_type->get_primitive_type());
// collect result
PExprResult expr_result;
std::string result;
- const auto& column_ptr = tmp_block.get_by_position(result_column).column;
- const auto& column_type = tmp_block.get_by_position(result_column).type;
+ const auto& column_ptr = tmp_data.column;
+ const auto& column_type = tmp_data.type;
// 4 from fe: Config.be_exec_version maybe need remove after next version, now in 2.1
if (_runtime_state->be_exec_version() >= 4 && params.__isset.is_nereids &&
params.is_nereids) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
index da4eb88d2a8..4568e641646 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
@@ -83,6 +83,7 @@ import org.apache.doris.proto.Types.PTypeDesc;
import org.apache.doris.proto.Types.PTypeNode;
import org.apache.doris.proto.Types.PValues;
import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.SessionVariable;
import org.apache.doris.rpc.BackendServiceProxy;
import org.apache.doris.system.Backend;
import org.apache.doris.thrift.TExpr;
@@ -319,6 +320,7 @@ public class FoldConstantRuleOnBE implements ExpressionPatternRuleFactory {
tQueryOptions.setBeExecVersion(Config.be_exec_version);
tQueryOptions.setEnableDecimal256(context.getSessionVariable().isEnableDecimal256());
tQueryOptions.setNewVersionUnixTimestamp(true);
+ tQueryOptions.setEnableStrictCast(SessionVariable.enableStrictCast());
TFoldConstantParams tParams = new TFoldConstantParams(paramMap, queryGlobals);
tParams.setVecExec(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org