This is an automated email from the ASF dual-hosted git repository.

gabriellee pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new 4492721ee1 [Bug](case function) do not crash if prepare failed 
(#15113) (#21977)
4492721ee1 is described below

commit 4492721ee1bc63efb8f5331693025a4b84010fe8
Author: htyoung <[email protected]>
AuthorDate: Thu Jul 20 11:25:55 2023 +0800

    [Bug](case function) do not crash if prepare failed (#15113) (#21977)
    
    (cherry picked from commit b2438b076dd9e3705e446c9839c67a735134b909)
    
    Co-authored-by: Gabriel <[email protected]>
---
 be/src/vec/exprs/vcase_expr.cpp      | 12 ------------
 be/src/vec/functions/function_case.h |  9 +--------
 2 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/be/src/vec/exprs/vcase_expr.cpp b/be/src/vec/exprs/vcase_expr.cpp
index 13c98b152c..c9bbec3d25 100644
--- a/be/src/vec/exprs/vcase_expr.cpp
+++ b/be/src/vec/exprs/vcase_expr.cpp
@@ -69,23 +69,11 @@ Status VCaseExpr::open(RuntimeState* state, VExprContext* 
context,
                        FunctionContext::FunctionStateScope scope) {
     RETURN_IF_ERROR(VExpr::open(state, context, scope));
     RETURN_IF_ERROR(VExpr::init_function_context(context, scope, _function));
-    if (scope == doris_udf::FunctionContext::FRAGMENT_LOCAL) {
-        auto* case_state = new CaseState {_data_type};
-        context->fn_context(_fn_context_index)
-                ->set_function_state(FunctionContext::FRAGMENT_LOCAL, 
case_state);
-    }
     return Status::OK();
 }
 
 void VCaseExpr::close(RuntimeState* state, VExprContext* context,
                       FunctionContext::FunctionStateScope scope) {
-    if (scope == doris_udf::FunctionContext::FRAGMENT_LOCAL) {
-        auto* case_state = reinterpret_cast<CaseState*>(
-                context->fn_context(_fn_context_index)
-                        ->get_function_state(FunctionContext::FRAGMENT_LOCAL));
-        delete case_state;
-    }
-
     VExpr::close_function_context(context, scope, _function);
     VExpr::close(state, context, scope);
 }
diff --git a/be/src/vec/functions/function_case.h 
b/be/src/vec/functions/function_case.h
index f6c825498b..abde876aa0 100644
--- a/be/src/vec/functions/function_case.h
+++ b/be/src/vec/functions/function_case.h
@@ -27,10 +27,6 @@
 
 namespace doris::vectorized {
 
-struct CaseState {
-    DataTypePtr result_type = nullptr;
-};
-
 template <bool has_case, bool has_else>
 struct FunctionCaseName;
 
@@ -378,10 +374,7 @@ public:
 
     Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
                         size_t result, size_t input_rows_count) override {
-        auto* case_state = reinterpret_cast<CaseState*>(
-                context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
-
-        return execute_get_type(case_state->result_type, block, arguments, 
result,
+        return execute_get_type(block.get_by_position(result).type, block, 
arguments, result,
                                 input_rows_count);
     }
 };


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to