在提交之前验证 Kusto 查询
Validate Kusto query before submitting it
有没有办法(在 Powershell 中最好,但也可以)在将其提交到集群之前检查 KQL 语法?
我想检查我的 CI 管道中 KQL 代码存储库的完整性。
谢谢!
是的,您可以使用 Kusto Query Language parser (.Net library) for this, start from the 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()
有没有办法(在 Powershell 中最好,但也可以)在将其提交到集群之前检查 KQL 语法?
我想检查我的 CI 管道中 KQL 代码存储库的完整性。
谢谢!
是的,您可以使用 Kusto Query Language parser (.Net library) for this, start from the 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()