Muokkaa

Jaa


parse_version()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Converts the input string representation of a version number into a decimal number that can be compared.

Syntax

parse_version (version)

Learn more about syntax conventions.

Parameters

Name Type Required Description
version string ✔️ The version to be parsed.

Note

  • version must contain from one to four version parts, represented as numbers and separated with dots ('.').
  • Each part of version may contain up to eight digits, with the max value at 99999999.
  • If the number of parts is less than four, all the missing parts are considered as trailing. For example, 1.0 == 1.0.0.0.

Returns

If conversion is successful, the result is a decimal; otherwise, the result is null.

Examples

Parse version strings

The following query shows version strings with their parsed version numbers.

let dt = datatable(v: string)
    [
    "0.0.0.5", "0.0.7.0", "0.0.3", "0.2", "0.1.2.0", "1.2.3.4", "1"
];
dt
| extend parsedVersion = parse_version(v)

Output

v parsedVersion
0.0.0.5 5
0.0.7.0 700,000,000
0.0.3 300,000,000
0.2 20,000,000,000,000,000
0.1.2.0 10,000,000,200,000,000
1.2.3.4 1,000,000,020,000,000,300,000,004
1 1,000,000,000,000,000,000,000,000

Compare parsed version strings

The following query identifies which labs have equipment needing updates by comparing their parsed version strings to the minimum version number "1.0.0.0".

let dt = datatable(lab: string, v: string)
[
    "Lab A", "0.0.0.5",
    "Lab B", "0.0.7.0",
    "Lab D","0.0.3",
    "Lab C", "0.2", 
    "Lab G", "0.1.2.0",
    "Lab F", "1.2.3.4",
    "Lab E", "1",
];
dt
| extend parsed_version = parse_version(v)
| extend needs_update = iff(parsed_version < parse_version("1.0.0.0"), "Yes", "No")
| project lab, v, needs_update
| sort by lab asc , v, needs_update

Output

lab v needs_update
Lab A 0.0.0.5 Yes
Lab B 0.0.7.0 Yes
Lab C 0.2 Yes
Lab D 0.0.3 Yes
Lab E 1 No
Lab F 1.2.3.4 No
Lab G 0.1.2.0 Yes