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

Function ProcessWildcardIndex

be/src/exprs/string-functions.cc:230–251  ·  view source on GitHub ↗

Process wildcard(*) in array selection. path_idx is the index after the wildcard in path_str. Return next unprocessed index in path_str. Return -1 for errors.

Source from the content-addressed store, hash-verified

228/// Process wildcard(*) in array selection. path_idx is the index after the wildcard in
229/// path_str. Return next unprocessed index in path_str. Return -1 for errors.
230static int ProcessWildcardIndex(FunctionContext* ctx, const StringVal& path_str,
231 int path_idx, JsonUdfValue* queue, JsonUdfAllocator* allocator) {
232 const uint8_t* path = path_str.ptr;
233 while (path_idx < path_str.len && path[path_idx] != ']') {
234 if (path[path_idx] != ' ') { // have something else illegal
235 string msg = Substitute("Failed to parse json path '$0': "
236 "Encountered '$1' in position $2, expects ' ' or ']'",
237 AnyValUtil::ToString(path_str), static_cast<char>(path[path_idx]), path_idx);
238 ctx->SetError(msg.c_str());
239 return -1;
240 }
241 ++path_idx;
242 }
243 if (path_idx == path_str.len) {
244 string msg = Substitute("Unclosed brackets in json path '$0'",
245 AnyValUtil::ToString(path_str));
246 ctx->SetError(msg.c_str());
247 return -1;
248 }
249 RETURN_IF_OOM(ExpandArrays(queue, allocator), -1);
250 return path_idx + 1; // path_idx points at ']'
251}
252
253/// Process number in array selection. path_idx points at the start of the number in
254/// path_str. Return next unprocessed index in path_str. Return -1 for errors.

Callers 1

GetJsonObjectImplMethod · 0.85

Calls 4

SubstituteFunction · 0.85
ExpandArraysFunction · 0.85
ToStringFunction · 0.50
SetErrorMethod · 0.45

Tested by

no test coverage detected