diff --git a/src/sql/code_generator/ob_static_engine_cg.cpp b/src/sql/code_generator/ob_static_engine_cg.cpp index 0169c458bd..0589431d42 100644 --- a/src/sql/code_generator/ob_static_engine_cg.cpp +++ b/src/sql/code_generator/ob_static_engine_cg.cpp @@ -9042,10 +9042,23 @@ int ObStaticEngineCG::get_phy_op_type(ObLogicalOperator &log_op, int tmp_ret = OB_SUCCESS; tmp_ret = OB_E(EventTable::EN_DISABLE_VEC_WINDOW_FUNCTION) OB_SUCCESS; bool use_vec2_winfunc = (GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_3_2_0); - if (use_rich_format && use_vec2_winfunc && tmp_ret == OB_SUCCESS + int batch_size = 0; + if (OB_ISNULL(log_op.get_plan())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null plan", K(ret)); + } else { + batch_size = log_op.get_plan()->get_optimizer_context().get_batch_size(); + } + if (OB_FAIL(ret)) { + } else if (use_rich_format && use_vec2_winfunc && tmp_ret == OB_SUCCESS && ObWindowFunctionVecOp::all_supported_winfuncs( static_cast(&log_op)->get_window_exprs())) { - type = PHY_VEC_WINDOW_FUNCTION; + if (static_cast(&log_op)->is_range_dist_parallel() + && batch_size < ObWindowFunctionVecSpec::RD_MIN_BATCH_SIZE) { + type = PHY_WINDOW_FUNCTION; + } else { + type = PHY_VEC_WINDOW_FUNCTION; + } } else { type = PHY_WINDOW_FUNCTION; } diff --git a/src/sql/engine/window_function/ob_window_function_vec_op.cpp b/src/sql/engine/window_function/ob_window_function_vec_op.cpp index 43c8efea72..e2479d354b 100644 --- a/src/sql/engine/window_function/ob_window_function_vec_op.cpp +++ b/src/sql/engine/window_function/ob_window_function_vec_op.cpp @@ -3741,6 +3741,7 @@ int ObWindowFunctionVecSpec::rd_generate_patch(RDWinFuncPXPieceMsgCtx &msg_ctx, // but expr data are filled with datums, unexpected errors will happen. for (int i = 0; OB_SUCC(ret) && i < rd_coord_exprs_.count(); i++) { VectorFormat default_fmt = rd_coord_exprs_.at(i)->get_default_res_format(); + // TODO: @zongmei.zzm support batch_size < 4 for range distribution if (OB_FAIL(rd_coord_exprs_.at(i)->init_vector_for_write( eval_ctx, rd_coord_exprs_.at(i)->is_const_expr() ? VEC_UNIFORM_CONST : VEC_UNIFORM, 4))) { LOG_WARN("init vector failed", K(ret)); diff --git a/src/sql/engine/window_function/ob_window_function_vec_op.h b/src/sql/engine/window_function/ob_window_function_vec_op.h index f40fb88b4d..aec6b97d09 100644 --- a/src/sql/engine/window_function/ob_window_function_vec_op.h +++ b/src/sql/engine/window_function/ob_window_function_vec_op.h @@ -40,6 +40,8 @@ class RDWinFuncPXPartialInfo; class ObWindowFunctionVecSpec: public ObWindowFunctionSpec { OB_UNIS_VERSION_V(1); +public: + static const int64_t RD_MIN_BATCH_SIZE = 4; public: ObWindowFunctionVecSpec(common::ObIAllocator &alloc, const ObPhyOperatorType type) : ObWindowFunctionSpec(alloc, type)