在Azure Data Explorer(Kusto)中从查询创建物化视图

huangapple go评论62阅读模式
英文:

Creating materialized view from a query in Azure Data Explorer (Kusto)

问题

I'm here to assist with your translation request. Here's the translated content:

需要一些关于 Kusto(Azure Data Explorer)的帮助。

是否可以将此查询转换为材料化视图?

customobject
| join kind=inner (
    customobject
    | summarize max_dp_adf_copy_start_time = max(dp_adf_copy_start_time) by accountId, id
    )
    on
         $left.accountId == $right.accountId
         and $left.id == $right.id
         and $left.dp_adf_copy_start_time == $right.max_dp_adf_copy_start_time

我尝试过这个,但它返回了语法错误 预期: )

.create materialized-view mvw_customobject on table customobject
{
customobject 
| join kind=inner (
    customobject
    | summarize max_dp_adf_copy_start_time = max(dp_adf_copy_start_time) by accountId, id
    )
    on
         $left.accountId == $right.accountId
         and $left.id == $right.id
         and $left.dp_adf_copy_start_time == $right.max_dp_adf_copy_start_time
}

非常感谢您的帮助!

最好的祝愿 在Azure Data Explorer(Kusto)中从查询创建物化视图

英文:

Need some help with Kusto (Azure Data Explorer).

Is it possible to convert this query into a materialized view?

customobject
| join kind=inner (
    customobject
    | summarize max_dp_adf_copy_start_time = max(dp_adf_copy_start_time) by accountId, id
    )
    on
         $left.accountId == $right.accountId
         and $left.id == $right.id
         and $left.dp_adf_copy_start_time == $right.max_dp_adf_copy_start_time

I have tried this, but it comes back with Syntax Error Expected: ):

.create materialized-view mvw_customobject on table customobject
{
customobject 
| join kind=inner (
    customobject
    | summarize max_dp_adf_copy_start_time = max(dp_adf_copy_start_time) by accountId, id
    )
    on
         $left.accountId == $right.accountId
         and $left.id == $right.id
         and $left.dp_adf_copy_start_time == $right.max_dp_adf_copy_start_time
}

Much help would be appreciated!

Best Regards 在Azure Data Explorer(Kusto)中从查询创建物化视图

答案1

得分: 1

我已在我的环境中复现,并以下是我的观察和遵循的Microsoft文档

我一开始也遇到了类似的情况:

在Azure Data Explorer(Kusto)中从查询创建物化视图

在这里,在您的查询和我的查询中,问题出在了summarize语句上,summarize语句应该作为创建视图的最后一条语句,并且只能使用一个summarize语句。当我进行了类似的更改后,它成功执行如下:

示例1:

.create materialized-view mvw_customobject5 on table chotu
{
    chotu
    | join kind = inner (chotu) on $left.EventId==$right.EventId
    |summarize take_any(*) by EventId
}

在Azure Data Explorer(Kusto)中从查询创建物化视图

示例2:

.create materialized-view mvw_customobject00 on table chotu
{
    chotu
    | join kind = inner (chotu
    |project EventId) on $left.EventId==$right.EventId
    |summarize take_any(*) by EventId
}

在Azure Data Explorer(Kusto)中从查询创建物化视图

您可以清楚地查看我提供的文档,尝试遵循示例并执行操作,您将能够像我一样创建视图。

英文:

I have reproduced in my environment and below are my observations and followed Microsoft-Document:

I have got similar as you have at first:

在Azure Data Explorer(Kusto)中从查询创建物化视图

Here, in yours and my query the problem was with summarize statement as summarize statement should come as last statement while creating the view and only one summarize statement should be used. When I made similar changes it got executed like below:

Example1:

.create materialized-view mvw_customobject5 on table chotu
{
    chotu
    | join kind = inner (chotu) on $left.EventId==$right.EventId
    |summarize take_any(*) by EventId
}

在Azure Data Explorer(Kusto)中从查询创建物化视图

Example2:

.create materialized-view mvw_customobject00 on table chotu
{
    chotu
    | join kind = inner (chotu
    |project EventId) on $left.EventId==$right.EventId
    |summarize take_any(*) by EventId
}

在Azure Data Explorer(Kusto)中从查询创建物化视图

You can clearly check the document which I have provided, try to follow the examples and do it, you will get view created as I have got mine.

答案2

得分: 0

我找到了解决方案。要获得我寻找的结果,在Kusto(ADX)中,我不需要使用连接操作:

.create materialized-view mvw_customobject on table customobject
{
customobject
    | 根据 accountId、id 汇总 arg_max(dp_adf_copy_start_time, *) 
}
英文:

I found the solution. To get the result I was looking for, in Kusto (ADX) I did not need the join:

.create materialized-view mvw_customobject on table customobject
{
customobject
    | summarize arg_max(dp_adf_copy_start_time, *) by accountId, id
}

huangapple
  • 本文由 发表于 2023年7月18日 05:46:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76708270.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定