【发布时间】:2021-11-30 08:33:34
【问题描述】:
有没有办法(在 Powershell 中最好,但也可以)在将 KQL 语法提交到集群之前检查它?
我想检查我的 CI 管道中 KQL 代码仓库的健全性。
谢谢!
【问题讨论】:
有没有办法(在 Powershell 中最好,但也可以)在将 KQL 语法提交到集群之前检查它?
我想检查我的 CI 管道中 KQL 代码仓库的健全性。
谢谢!
【问题讨论】:
是的,您可以为此使用Kusto Query Language parser (.Net library),从samples 文档开始。
【讨论】:
第 1 步:安装:
Install-PackageProvider -Name NuGet -Scope CurrentUser
Register-PackageSource -Name nuget.org -ProviderName NuGet -Location https://www.nuget.org/api/v2
Install-Package -Name Microsoft.Azure.Kusto.Language -ProviderName NuGet -scope CurrentUser
第 2 步:运行查询:
$kql="T | project a = a + b | where a > 10.0"
$nuGetPath=Get-Package -Name "Microsoft.Azure.Kusto.Language" | Select-Object -ExpandProperty Source
$dllPath=(Split-Path -Path $nuGetPath) + "\lib\netstandard2.0\Kusto.Language.dll"
[System.Reflection.Assembly]::LoadFrom($dllPath)
$kustoParse=[Kusto.Language.KustoCode]::Parse($kql)
$kustoParse.getDiagnostics()
【讨论】: