parse_version()parse_version()

将版本的输入字符串表示形式转换为可比较的十进制数。Converts the input string representation of version to a comparable decimal number.

parse_version("0.0.0.1")

语法Syntax

parse_version ( Expr )parse_version ( Expr )

参数Arguments

  • Expr :类型为 string 的标量表达式,指定要解析的版本。Expr: A scalar expression of type string that specifies the version to be parsed.

返回Returns

如果转换成功,则结果将为小数。If conversion is successful, the result will be a decimal. 如果转换不成功,则结果将为 nullIf conversion is unsuccessful, the result will be null.

备注Notes

输入字符串必须包含一到四个版本部分,用数字表示,并用点(“.”)分隔。Input string must contain from one to four version parts, represented as numbers and separated with dots ('.').

版本的每个部分最多可包含八个数字,最大值为 99999999。Each part of version may contain up to eight digits, with the max value at 99999999.

如果少于四个部分,则所有缺少的部分将被视为尾随部分 (1.0 == 1.0.0.0)。If the number of parts is less than four, all the missing parts are considered as trailing (1.0 == 1.0.0.0).

示例Example

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","99999999.0.0.0"];
dt | project v1=v, _key=1 
| join kind=inner (dt | project v2=v, _key = 1) on _key | where v1 != v2
| summarize v1 = max(v1),v2 = min(v2) by (hash(v1) + hash(v2)) // removing duplications
| project v1, v2, higher_version = iif(parse_version(v1) > parse_version(v2), v1, v2)

v1v1 v2v2 更高版本higher_version
99999999.0.0.099999999.0.0.0 0.0.0.50.0.0.5 99999999.0.0.099999999.0.0.0
11 0.0.0.50.0.0.5 11
1.2.3.41.2.3.4 0.0.0.50.0.0.5 1.2.3.41.2.3.4
0.1.2.00.1.2.0 0.0.0.50.0.0.5 0.1.2.00.1.2.0
0.20.2 0.0.0.50.0.0.5 0.20.2
0.0.30.0.3 0.0.0.50.0.0.5 0.0.30.0.3
0.0.7.00.0.7.0 0.0.0.50.0.0.5 0.0.7.00.0.7.0
99999999.0.0.099999999.0.0.0 0.0.7.00.0.7.0 99999999.0.0.099999999.0.0.0
11 0.0.7.00.0.7.0 11
1.2.3.41.2.3.4 0.0.7.00.0.7.0 1.2.3.41.2.3.4
0.1.2.00.1.2.0 0.0.7.00.0.7.0 0.1.2.00.1.2.0
0.20.2 0.0.7.00.0.7.0 0.20.2
0.0.7.00.0.7.0 0.0.30.0.3 0.0.7.00.0.7.0
99999999.0.0.099999999.0.0.0 0.0.30.0.3 99999999.0.0.099999999.0.0.0
11 0.0.30.0.3 11
1.2.3.41.2.3.4 0.0.30.0.3 1.2.3.41.2.3.4
0.1.2.00.1.2.0 0.0.30.0.3 0.1.2.00.1.2.0
0.20.2 0.0.30.0.3 0.20.2
99999999.0.0.099999999.0.0.0 0.20.2 99999999.0.0.099999999.0.0.0
11 0.20.2 11
1.2.3.41.2.3.4 0.20.2 1.2.3.41.2.3.4
0.20.2 0.1.2.00.1.2.0 0.20.2
99999999.0.0.099999999.0.0.0 0.1.2.00.1.2.0 99999999.0.0.099999999.0.0.0
11 0.1.2.00.1.2.0 11
1.2.3.41.2.3.4 0.1.2.00.1.2.0 1.2.3.41.2.3.4
99999999.0.0.099999999.0.0.0 1.2.3.41.2.3.4 99999999.0.0.099999999.0.0.0
1.2.3.41.2.3.4 11 1.2.3.41.2.3.4
99999999.0.0.099999999.0.0.0 11 99999999.0.0.099999999.0.0.0