MCPcopy Create free account
hub / github.com/apache/impala / OpenEvaluator

Method OpenEvaluator

be/src/exprs/cast-format-expr.cc:29–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27using namespace datetime_parse_util;
28
29Status CastFormatExpr::OpenEvaluator(FunctionContext::FunctionStateScope scope,
30 RuntimeState* state, ScalarExprEvaluator* eval) const {
31 DCHECK(eval != nullptr);
32 RETURN_IF_ERROR(ScalarFnCall::OpenEvaluator(scope, state, eval));
33 if (scope != FunctionContext::FRAGMENT_LOCAL) return Status::OK();
34 DCHECK_GE(fn_ctx_idx_, 0);
35 FunctionContext* fn_ctx = eval->fn_context(fn_ctx_idx_);
36
37 std::unique_ptr<DateTimeFormatContext> dt_ctx =
38 std::make_unique<DateTimeFormatContext>(format_.c_str(), format_.length());
39 bool accept_time_toks = (fn_ctx->GetReturnType().type != FunctionContext::TYPE_DATE &&
40 fn_ctx->GetArgType(0)->type != FunctionContext::TYPE_DATE);
41 IsoSqlFormatTokenizer format_tokenizer(dt_ctx.get(), GetCastMode(fn_ctx),
42 accept_time_toks);
43 FormatTokenizationResult parse_result = format_tokenizer.Tokenize();
44 if (parse_result != FormatTokenizationResult::SUCCESS) {
45 ReportBadFormat(fn_ctx, parse_result, StringVal(format_.c_str()), true);
46 return Status(TErrorCode::INTERNAL_ERROR, fn_ctx->error_msg());
47 }
48 dt_ctx->SetCenturyBreakAndCurrentTime(*fn_ctx->impl()->state()->now());
49 fn_ctx->SetFunctionState(scope, dt_ctx.release());
50
51 return Status::OK();
52}
53
54void CastFormatExpr::CloseEvaluator(FunctionContext::FunctionStateScope scope,
55 RuntimeState* state, ScalarExprEvaluator* eval) const {

Callers

nothing calls this directly

Calls 15

OKFunction · 0.85
ReportBadFormatFunction · 0.85
StringValClass · 0.85
fn_contextMethod · 0.80
GetArgTypeMethod · 0.80
error_msgMethod · 0.80
nowMethod · 0.80
implMethod · 0.80
SetFunctionStateMethod · 0.80
StatusClass · 0.70
getMethod · 0.65

Tested by

no test coverage detected