Multiple toint check

53 views Asked by At

I have this query to check the application version

AppInventory_CL
| extend AppVersion_s_Dyn = split(AppVersion_s, '.')
| extend Versione = iif(toint(AppVersion_s_Dyn[0]) >= 5 
    and toint(AppVersion_s_Dyn[1]) >= 2 
    and toint(AppVersion_s_Dyn[2]) >= 7, 'OK', 'KO')

But I need that also superior versions such as 6.0.5 is OK. How can I do that? Thanks

1

There are 1 answers

0
John Gardner On

Presuming the versions are well formatted, you might want to use the parse_version function?

See https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/parse-versionfunction

where that function might do what you want, and then you can use standard equals/greater than operators on the version strings?

edit: from a deleted answer that should have been a comment:

Yes I saw it but If I use parse_version the version for example 5.2.7 became 5000000020000000700000000 and if I try this

| extend Versione = iff(parse_version(AppVersion_s) >= 5000000020000000700000000, 'OK', 'KO')

I have this error

Query could not be parsed at '5000000020000000700000000' on line [7,56] Token: '5000000020000000700000000' Line: 7 Postion: 56

if you look at the examples from the link, you wouldn't use the big numbers even if that's what it prints out if you use it in a query, you'd use parse_version on both sides of the operator:

iff(parse_version(AppVersion_s) >= parse_version("5.2.7"), 'OK', 'KO')

basically, let the parse_version do its internal things, and don't directly use the values it returns