【问题标题】:esper aggregation count query output unexpectedesper 聚合计数查询输出意外
【发布时间】:2014-06-30 22:50:45
【问题描述】:

我正在向 esper 发送城市名称、公司名称。

这些查询将在 5 秒内计算名称公司对的出现次数:

create context FiveSecondsContext start @now end after 5 seconds; 

context FiveSecondsContext 
        insert into AggregatedEvent1 
                        select count(*) as count, company, name from eBay group by name, company output snapshot when terminated; 

下面的查询应该在 FiveSecondsContext 的末尾给出每个城市的最大计数。就我对 SQL 的了解而言,这似乎是正确的,但它并没有给我最大值,它返回 AggregatedEvent1 中的所有行。

   insert into AggrEvent2 
                select max(count) as value, company, name from AggregatedEvent1 group by name; 

由于上面出错了,下面我的查询

select count(*) as cnt, company from AggrEvent2 group by company; 

它试图计算公司(例如:“yahoo”)具有最大计数的城市名称也会出错,并在初始查询输入中为我提供公司名称的所有出现次数。

  1. 要么是 groupby 子句的问题,要么是
  2. 我需要确定查询运行的顺序。因为我只有为 AggregatedEvent1 定义的上下文。

【问题讨论】:

    标签: streaming complex-event-processing esper


    【解决方案1】:

    这取决于选择中的内容和组中的内容,与关系数据库中的相同。你可以在这里阅读:http://esper.codehaus.org/esper-5.0.0/doc/reference/en-US/html_single/index.html#processingmodel_aggregation_output 从选择中删除“公司”或将公司添加到组中似乎可以做到这一点。

    【讨论】:

    • 不确定是聚合还是上下文问题
    猜你喜欢
    • 2013-01-04
    • 2018-06-18
    • 2021-09-25
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    • 1970-01-01
    • 2022-11-16
    相关资源
    最近更新 更多