[ https://issues.apache.org/jira/browse/KYLIN-2449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15952480#comment-15952480 ]
liyang commented on KYLIN-2449: ------------------------------- Nice patch!! Thanks Kaige! > Rewrite should not run on OLAPAggregateRel if has no OLAPTable > -------------------------------------------------------------- > > Key: KYLIN-2449 > URL: https://issues.apache.org/jira/browse/KYLIN-2449 > Project: Kylin > Issue Type: Bug > Reporter: Kaige Liu > Assignee: Kaige Liu > Fix For: v2.0.0 > > Attachments: KYLIN-2449.patch > > > If a OLAPAggregateRel's context does not contain any OLAPTable, it's no need > to rewrite column. Otherwise a NPE will be threw, for example: > {code} > Caused by: java.lang.NullPointerException > at > org.apache.kylin.query.relnode.OLAPAggregateRel.buildRewriteColumn(OLAPAggregateRel.java:217) > at > org.apache.kylin.query.relnode.OLAPAggregateRel.buildRewriteFieldsAndMetricsColumns(OLAPAggregateRel.java:340) > at > org.apache.kylin.query.relnode.OLAPAggregateRel.implementRewrite(OLAPAggregateRel.java:259) > at > org.apache.kylin.query.relnode.OLAPRel$RewriteImplementor.visitChild(OLAPRel.java:158) > at > org.apache.kylin.query.relnode.OLAPSortRel.implementRewrite(OLAPSortRel.java:83) > at > org.apache.kylin.query.relnode.OLAPRel$RewriteImplementor.visitChild(OLAPRel.java:158) > at > org.apache.kylin.query.relnode.OLAPLimitRel.implementRewrite(OLAPLimitRel.java:105) > at > org.apache.kylin.query.relnode.OLAPRel$RewriteImplementor.visitChild(OLAPRel.java:158) > at > org.apache.kylin.query.relnode.OLAPToEnumerableConverter.implement(OLAPToEnumerableConverter.java:94) > at > org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:108) > at > org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:92) > at > org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1233) > at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:303) > at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:200) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:761) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:617) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:587) > at > org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:215) > at > org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:594) > at > org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:615) > at > org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:148) > ... 35 more > {code} > Test case: > {code} > SELECT > t1.leaf_categ_id, COUNT(*) AS nums > FROM > (SELECT > leaf_categ_id > FROM > test_kylin_fact > WHERE > lstg_format_name = 'ABIN') t1 > JOIN > (SELECT > leaf_categ_id > FROM > test_kylin_fact f > INNER JOIN test_order o ON f.order_id = o.order_id > WHERE > buyer_id > 100) t2 ON t1.leaf_categ_id = t2.leaf_categ_id > GROUP BY t1.leaf_categ_id > ORDER BY t1.leaf_categ_id > LIMIT 10 > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)