gpt4 book ai didi

mysql - 在 Mondrian 4 中创建 MeasureExpression 时的表别名

转载 作者:行者123 更新时间:2023-11-29 02:57:16 25 4
gpt4 key购买 nike

我正在尝试创建一个指示器,该指示器表示已下订单的客户的不同计数。蒙德里安模式的相关部分如下:

<Measure name="Active Customers" formatString="#" aggregator="distinct-count">
<MeasureExpression>
<SQL dialect="mysql">
CASE WHEN <Column name ='placed_count'/> &gt; 0 THEN 1 END
</SQL>
</MeasureExpression>
</Measure>

出于某种原因,列名未被其列名(包括表别名)替换。我可以在日志中查看:

Caused by: mondrian.olap.MondrianException: Mondrian Error:Internal error: Error while loading segment; sql=[select `v_dm_calendar`.`calendar_date` as `c0`, count(distinct CASE WHEN  > 0 THEN 1 END) as `m0` from `v_dm_calendar` as `v_dm_calendar`, `fc_customer_activity_sportsbook` as `fc_customer_activity_sportsbook` where `fc_customer_activity_sportsbook`.`bet_date` = `v_dm_calendar`.`calendar_date` and `v_dm_calendar`.`calendar_date` = '2015-03-30' group by `v_dm_calendar`.`calendar_date`]
at mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:972)
at mondrian.olap.Util.newInternal(Util.java:2404)
at mondrian.olap.Util.newError(Util.java:2420)
at mondrian.rolap.SqlStatement.handle(SqlStatement.java:353)
at mondrian.rolap.SqlStatement.execute(SqlStatement.java:253)
at mondrian.rolap.RolapUtil.executeQuery(RolapUtil.java:350)
at mondrian.rolap.agg.SegmentLoader.createExecuteSql(SegmentLoader.java:625)
... 8 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '> 0 THEN 1 END) as `m0` from `v_dm_calendar` as `v_dm_calendar`, `fc_customer_ac' at line 1

我是否遗漏了语法中的某些内容?我在官方文档和蒙德里安的书中都找不到任何东西。

最佳答案

Mondrian 3中会这样定义:

<MeasureExpression>
<SQL dialect="generic">
<![CDATA[case when placed_count > 0 then 1 else 0 end]]>
</SQL>
</MeasureExpression>

Mondrian 4 中你需要添加 calculated column到事实表的声明并创建一个 measure based upon it :

<Table name="??">
<ColumnDefs>
<CalculatedColumnDef name="active_customers">
<ExpressionView>
<SQL dialect="generic">
(case when <Column name="placed_count"/> &gt;
0 then 1 end)
</SQL>
</ExpressionView>
</CalculatedColumnDef>
</ColumnDefs>
</Table>

<Measure name="Active Customers" aggregator="distinct-count" column="active_customers" formatString="#">

有关更多信息,请比较一节 3.2 MeasuresMondrian 4Mondrian 3文档。

关于mysql - 在 Mondrian 4 中创建 MeasureExpression 时的表别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29367300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com