Mondrain支持kylin问题解决

Mondrain支持kylin问题解决

Mdx

select

 {[MEASURES].[UNITPRICE],[MEASURES].[NUMBER]} on columns,

 {[CUSTOMER].[GENDER].members} on rows

from saleinfo

问题

问题1: mondrian转换过来的sql kylin不支持:Cartesian Join is not supported. while executing SQL: "select "CUSTOMER"."GENDER" as "c0", sum("SALE"."UNITPRICE") as "m0", sum("SALE"."NUMBER") as "m1" from "SALE" as "SALE", "CUSTOMER" as "CUSTOMER" where "SALE"."CUSID" = "CUSTOMER"."CUSID" group by "CUSTOMER"."GENDER"

不支持笛卡儿积的写法=》对应源码修改1,2,3

 

问题2:No realization found for OLAPContext, MODEL_UNMATCHED_JOIN, rel#993:OLAPTableScan.OLAP.[](table=[PUBLIC, SALE],ctx=,fields=[0, 1, 2, 3, 4, 5, 6, 7]), JoinDesc [type=INNER, primary_key=[CUSID], foreign_key=[CUSID]] while executing SQL: "select "CUSTOMER"."GENDER" as "c0", sum("SALE"."UNITPRICE") as "m0", sum("SALE"."NUMBER") as "m1" from "SALE" as "SALE" join "CUSTOMER" as "CUSTOMER" on "SALE"."CUSID" = "CUSTOMER"."CUSID" group by "CUSTOMER"."GENDER

  源码修改1,2,3执行完之后,转换出的sql 中join 没有带left,kylin不支持。对应解决方法是修改4。

源码修改

1.Dialect.java的枚举类型DatabaseProduct中新增KYLIN.

2.JdbcDialectImpl.java的getProduct中新增对kyin的支持:else if (upperProductName.equals("KYLIN")){

            return DatabaseProduct.KYLIN;

        }

3.新增KylinDialect.java类

/**

 * @author wangzhou

 * @date 2018年7月10日

 * 增加kylin支持

 */

package mondrian.spi.impl;

 

import java.sql.*;

import mondrian.spi.*;

 

public class KylinDialect extends JdbcDialectImpl {

       public static final JdbcDialectFactory FACTORY;

   

    public KylinDialect(final Connection connection) throws SQLException {

        super(connection);

    }

   

    public boolean allowsCountDistinct() {

        return false;

    }

   

    public boolean allowsJoinOn() {

        return true;

    }

   

    static {

        FACTORY = new JdbcDialectFactory(KylinDialect.class, Dialect.DatabaseProduct.KYLIN) {

            protected boolean acceptsConnection(final Connection connection) {

                return super.acceptsConnection(connection);

            }

        };

    }

}

 

4.修改SqlQuery.java的toBuffer()中的三目运算String fromSep = joinCount > 0 ? " join " : ", ";修改为String fromSep = joinCount > 0 ? " left join " : ", ";

上一篇:【五】Docker中安装svn


下一篇:Kylin 设置邮件报警、用户管理和自定义数据源切换