在 Kusto 中用 null 替换空字符串列

Replacing empty string column with null in Kusto

如何用空值替换字符串数据类型的空(非空)列?

所以说下面的查询returns非零记录集:-

mytable | where mycol == ""

现在这些是 mycol 包含空字符串的行。我想用空值替换这些。现在,根据我在 kusto 文档中阅读的内容,我们有特定于数据类型的 null 文字,例如 int(null)、datetime(null)、guid(null) 等。但是没有 string(null)。最接近字符串的是guid,但是当我按照下面的方式使用它时,我得到一个错误:-

mytable | where mycol == "" | extend test = translate(mycol,guid(null))

错误:-

translate(): argument #0 must be string literal

那么出路在哪里呢?

更新:-

datatable(n:int,s:string)
[
    10,"hello",
    10,"",
    11,"world",
    11,"",
    12,""
]
| summarize myset=make_set(s) by n

如果执行此操作,您会看到空字符串被视为集合的一部分。我不想要这个,这样的空字符串不应该是我的数组的一部分。但与此同时我不想丢失 n 的值,这正是我使用 isnotempty 函数时会发生的情况。所以在下面的例子中,可以看到没有返回n=12的行,没有必要跳过n=12,总能得到一个空数组:-

datatable(n:int,s:string)
[
    10,"hello",
    10,"",
    11,"world",
    11,"",
    12,""
]
| where isnotempty(s)
| summarize myset=make_set(s) by n

目前不支持 null 字符串数据类型的值:https://docs.microsoft.com/en-us/azure/kusto/query/scalar-data-types/null-values

我很确定,就其本身而言,这不应该阻止您实现最终目标,但该目标目前尚不明确。

[根据您的更新进行更新:]

datatable(n:int,s:string)
[
    10,"hello",
    10,"",
    11,"world",
    11,"",
    12,""
]
| summarize make_set(todynamic(s)) by n