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

Method ParseUrl

be/src/exprs/string-functions-ir.cc:1384–1413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382}
1383
1384StringVal StringFunctions::ParseUrl(
1385 FunctionContext* ctx, const StringVal& url, const StringVal& part) {
1386 if (url.is_null || part.is_null) return StringVal::null();
1387 void* state = ctx->GetFunctionState(FunctionContext::FRAGMENT_LOCAL);
1388 UrlParser::UrlPart url_part;
1389 if (state != NULL) {
1390 url_part = *reinterpret_cast<UrlParser::UrlPart*>(state);
1391 } else {
1392 DCHECK(!ctx->IsArgConstant(1));
1393 url_part = UrlParser::GetUrlPart(StringValue::FromStringVal(part));
1394 }
1395
1396 StringValue result;
1397 if (!UrlParser::ParseUrl(StringValue::FromStringVal(url), url_part, &result)) {
1398 // url is malformed, or url_part is invalid.
1399 if (url_part == UrlParser::INVALID) {
1400 stringstream ss;
1401 ss << "Invalid URL part: " << AnyValUtil::ToString(part);
1402 ctx->AddWarning(ss.str().c_str());
1403 } else {
1404 stringstream ss;
1405 ss << "Could not parse URL: " << AnyValUtil::ToString(url);
1406 ctx->AddWarning(ss.str().c_str());
1407 }
1408 return StringVal::null();
1409 }
1410 StringVal result_sv;
1411 result.ToStringVal(&result_sv);
1412 return result_sv;
1413}
1414
1415void StringFunctions::ParseUrlClose(
1416 FunctionContext* ctx, FunctionContext::FunctionStateScope scope) {

Callers

nothing calls this directly

Calls 6

GetFunctionStateMethod · 0.80
IsArgConstantMethod · 0.80
AddWarningMethod · 0.80
ToStringFunction · 0.50
strMethod · 0.45
ToStringValMethod · 0.45

Tested by

no test coverage detected