First query string parameter not parsed

1.1k views Asked by At

My query must extract a query string parameter from a URL in a data column. Unfortunately, Kusto appears bugged in that the base URL is considered part of the first parameter's name as indicated in this example:

datatable (MyUrl:string)
[
"http://foo/?p1=bar&p2=baz",
"http://foo/?p1=bar&p2=quuz",
"http://roo/?p1=biz&p2=fizz"
]
| project parse_urlquery(MyUrl)["Query Parameters"]["http://foo/?p1"], parse_urlquery(MyUrl)["Query Parameters"]["p1"], parse_urlquery(MyUrl)["Query Parameters"]["p2"]

Kusto output

How can I reliably extract p1 (Note, it's not necessarily first in the actual URL).

1

There are 1 answers

1
Yoni L. On BEST ANSWER

did you perhaps intend to use parse_url() and not parse_urlquery()?

datatable (MyUrl:string)
[
"http://foo/?p1=bar&p2=baz",
"http://foo/?p1=bar&p2=quuz",
"http://roo/?p1=biz&p2=fizz"
]
| project parse_url(MyUrl)["Query Parameters"]
Query Parameters
----------------
{
  "p1": "bar",
  "p2": "baz"
}
----------------
{
  "p1": "bar",
  "p2": "quuz"
}
----------------
{
  "p1": "biz",
  "p2": "fizz"
}