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

Function GetDigitFromString

be/src/exprs/mask-functions-ir.cc:432–442  ·  view source on GitHub ↗

Get digit (masked_number) from StringVal. Only accept digits or -1.

Source from the content-addressed store, hash-verified

430
431/// Get digit (masked_number) from StringVal. Only accept digits or -1.
432static inline bool GetDigitFromString(FunctionContext* ctx, const StringVal& str,
433 int* res) {
434 if (str.len != 1 || str.ptr[0] < '0' || str.ptr[0] > '9') {
435 ctx->SetError(Substitute(
436 "Can't convert '$0' to a valid masked_number. Valid values: 0-9.",
437 AnyValUtil::ToString(str)).c_str());
438 return false;
439 }
440 *res = str.ptr[0] - '0';
441 return true;
442}
443
444/// MaskShowFirstN overloads for string value
445StringVal MaskFunctions::MaskShowFirstN(FunctionContext* ctx, const StringVal& val) {

Callers 5

MaskShowFirstNMethod · 0.85
MaskShowLastNMethod · 0.85
MaskFirstNMethod · 0.85
MaskLastNMethod · 0.85
MaskMethod · 0.85

Calls 3

SubstituteFunction · 0.85
ToStringFunction · 0.50
SetErrorMethod · 0.45

Tested by

no test coverage detected