使用 Lambda 扩展 Table
Using Lambda to Extend Table
我正在尝试将一些逻辑从主查询移到 lambda 中,以便主查询更易于阅读。
所以我想采用这样的逻辑:
T //columns: operation_Name
| extend path_Label = iif(operation_Name == '/', 'home', 'other')
//end up with columns: operation_Name, path_Label
我想将 iif
逻辑移动到 lambda 中:
let translate_path = (operation_Name: string)
{
iif(operation_Name == '/', 'home', 'other')
};
T
| extend path_Label = invoke translate_path(operation_Name)
也尝试过:
let translate_path = (T:(operation_Name: string))`
{
T | extend path_Label = iif(operation_Name == '/', 'home', 'other')
};
T
| invoke translate_path()
不需要添加"invoke"。如果没有它,您的第一次尝试应该也能正常工作:
let translate_path = (operation_Name: string)
{
iif(operation_Name == '/', 'home', 'other')
};
T
| extend path_Label = translate_path(operation_Name)
我正在尝试将一些逻辑从主查询移到 lambda 中,以便主查询更易于阅读。
所以我想采用这样的逻辑:
T //columns: operation_Name
| extend path_Label = iif(operation_Name == '/', 'home', 'other')
//end up with columns: operation_Name, path_Label
我想将 iif
逻辑移动到 lambda 中:
let translate_path = (operation_Name: string)
{
iif(operation_Name == '/', 'home', 'other')
};
T
| extend path_Label = invoke translate_path(operation_Name)
也尝试过:
let translate_path = (T:(operation_Name: string))`
{
T | extend path_Label = iif(operation_Name == '/', 'home', 'other')
};
T
| invoke translate_path()
不需要添加"invoke"。如果没有它,您的第一次尝试应该也能正常工作:
let translate_path = (operation_Name: string)
{
iif(operation_Name == '/', 'home', 'other')
};
T
| extend path_Label = translate_path(operation_Name)