Reputation: 13
I struggle with some strange behavior kusto query.
I logged json with field named date and ill try to get value from this field. I made a little POC and got two diferent behavior. When i called field as Date then the query executes fine. If I just rename it to date unfortunately I am not able to run the query.
Scenario 1.
let T = datatable(MyString:string) [ '{"Date":"2023-03-05T00:00:00.0000000Z","hour_start":"10:00","hour_end":"21:00","option":"recent"}' ]; T | project MyJson = parse_json(MyString) | extend Date_ = tostring(MyJson.Date)
Scenario 2.
let T = datatable(MyString:string) [ '{"date":"2023-03-05T00:00:00.0000000Z","hour_start":"10:00","hour_end":"21:00","option":"recent"}' ]; T | project MyJson = parse_json(MyString) | extend Date_ = tostring(MyJson.date)
How to handle with this query where fieldName equal date ?
Please see detailed descriptions
Upvotes: 1
Views: 252
Reputation: 44981
It seems you hit a reserved word.
use MyJson["date"]
(same goes for identifiers with spaces and/or special characters).
let T = datatable(MyString:string) [ '{"date":"2023-03-05T00:00:00.0000000Z","hour_start":"10:00","hour_end":"21:00","option":"recent"}' ];
T
| project MyJson = parse_json(MyString)
| extend Date_ = tostring(MyJson["date"])
MyJson | Date_ |
---|---|
{"date":"2023-03-05T00:00:00.0000000Z","hour_start":"10:00","hour_end":"21:00","option":"recent"} | 2023-03-05T00:00:00.0000000Z |
Upvotes: 0