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.
| 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. |
| 230 | static 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. |
no test coverage detected