Dhiraj
Dhiraj

Reputation: 3696

How to conditionally force fail a query in Kusto

How do I force a query to actually fail in Kusto depending on certain condition? Ideally the exact I need to force failure is the query returns 0 count.

MyTable | count | where Count==0 ... the query should fail

I am looking for actual technical failure and not just nulls etc. Basically if a certain query returns 0 count , I want the query to fail so that the corresponding Web API call will also get appropriate failure return code.

Upvotes: 0

Views: 1720

Answers (1)

Alexander Sloutsky
Alexander Sloutsky

Reputation: 3017

Can you check if assert() function helps your scenario? https://learn.microsoft.com/en-us/azure/kusto/query/assert-function

let Count = toscalar(
range x from 1 to 1 step 1 | count
);
print assert(Count != 0, "Count must be non-zero")

Upvotes: 3

Related Questions