microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.
Apache License 2.0
510 stars 97 forks source link

False positives - GetDiagnostics() while parsing #82

Closed DeepakRautela02 closed 1 year ago

DeepakRautela02 commented 1 year ago

Hi, I was trying to test my queries for any errors present in them, with the use of the library. But for the below cases, I'm getting errors identified by the GetDiagnostics() method, whereas when I run the same queries in the portal, the queries run successfully.

Query 1

let networkEvents =
  DeviceNetworkEvents
  | project-rename Name = RemoteUrl
  | summarize by Name;
let deviceEvents =
  DeviceEvents
  | extend query = extractjson("$.abc", AdditionalFields)  
  | project-rename Name = query
  | summarize by Name;
let ResultEvents =
  networkEvents  
  | union
  deviceEvents
  | summarize by Name;
ResultEvents

The error that I get from GetDiagnostics() method is : The name 'Name' does not refer to any known column, table, variable or function." where it is not able to identify the Name token in line 14.

Query 2

DeviceEvents
| summarize Column1Count = count(RemoteUrl) by InitiatingProcessFileName
| sort by Column1Count

Error: "The function 'count' expects no arguments."

Where both of the queries run successfully when run in the portal. Can you please look into it? Thank you.

DeepakRautela02 commented 1 year ago

Hi, Any update on this? Will you be able to take this up? Thank you.

mattwar commented 1 year ago

I've fixed the problem with Query1. Now I'm adding a warning for using count(x) since it is deprecated, and you should be using countif(x) instead.

mattwar commented 1 year ago

Both issues are fixed now.