| 46 | } |
| 47 | |
| 48 | Status CaseExpr::OpenEvaluator(FunctionContext::FunctionStateScope scope, |
| 49 | RuntimeState* state, ScalarExprEvaluator* eval) const { |
| 50 | RETURN_IF_ERROR(ScalarExpr::OpenEvaluator(scope, state, eval)); |
| 51 | DCHECK_GE(fn_ctx_idx_, 0); |
| 52 | FunctionContext* fn_ctx = eval->fn_context(fn_ctx_idx_); |
| 53 | CaseExprState* case_state = fn_ctx->Allocate<CaseExprState>(); |
| 54 | if (UNLIKELY(case_state == nullptr)) { |
| 55 | DCHECK(!fn_ctx->impl()->state()->GetQueryStatus().ok()); |
| 56 | return fn_ctx->impl()->state()->GetQueryStatus(); |
| 57 | } |
| 58 | fn_ctx->SetFunctionState(FunctionContext::THREAD_LOCAL, case_state); |
| 59 | |
| 60 | const ColumnType& case_val_type = has_case_expr_ ? GetChild(0)->type() |
| 61 | : ColumnType(TYPE_BOOLEAN); |
| 62 | RETURN_IF_ERROR(AllocateAnyVal(state, eval->expr_perm_pool(), case_val_type, |
| 63 | "Could not allocate expression value", &case_state->case_val)); |
| 64 | const ColumnType& when_val_type = |
| 65 | has_case_expr_ ? GetChild(1)->type() : GetChild(0)->type(); |
| 66 | RETURN_IF_ERROR(AllocateAnyVal(state, eval->expr_perm_pool(), when_val_type, |
| 67 | "Could not allocate expression value", &case_state->when_val)); |
| 68 | return Status::OK(); |
| 69 | } |
| 70 | |
| 71 | void CaseExpr::CloseEvaluator(FunctionContext::FunctionStateScope scope, |
| 72 | RuntimeState* state, ScalarExprEvaluator* eval) const { |
no test coverage detected