Pentaho Analysis - Mondrian
  1. Pentaho Analysis - Mondrian
  2. MONDRIAN-1200

User-defined function + profiling causes NPE in CalcWriter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Unknown Unknown
    • Resolution: Fixed
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Notice:
      When an issue is open, the "Fix Version/s" field conveys a target, not necessarily a commitment. When an issue is closed, the "Fix Version/s" field conveys the version that the issue was fixed in.
    • QA Validation Status:
      Not Yet Validated

      Description

      While making a query through OLAP4J (Using mondrian master)

      select {[Measures].[Profit]} ON COLUMNS,
        {CurrentDateMember([Time], "[""Time""]\.[1997]")} ON ROWS
      from [Sales 2]


      I get a NPE in mondrian:


           [exec] SELECT CurrentDateMember([Time],'[Time]\.[Year]\.[yyyy]').lag(15) ON ROWS,
           [exec] {[Measures].[Profit]} ON COLUMNS
           [exec] FROM [Sales 2]
           [exec] org.saiku.service.util.exception.SaikuServiceException: Can't execute query: 96BAA7B7-ED7A-0BB1-87AD-5C590B064250
           [exec] at org.saiku.service.olap.OlapQueryService.execute(OlapQueryService.java:226)
           [exec] at org.saiku.service.olap.OlapQueryService.executeMdx(OlapQueryService.java:316)
           [exec] at org.saiku.web.rest.resources.QueryResource.executeMdx(QueryResource.java:399)
           [exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           [exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           [exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           [exec] at java.lang.reflect.Method.invoke(Method.java:597)
           [exec] at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
           [exec] at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
           [exec] at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
           [exec] at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
           [exec] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
           [exec] at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
           [exec] at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
           [exec] at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
           [exec] at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
           [exec] at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
           [exec] at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
           [exec] at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
           [exec] at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
           [exec] at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
           [exec] at org.codehaus.enunciate.modules.jersey.EnunciateJerseyServletContainer.service(EnunciateJerseyServletContainer.java:248)
           [exec] at org.saiku.plugin.EnunciateJerseyPluginServlet.service(EnunciateJerseyPluginServlet.java:95)
           [exec] at org.saiku.plugin.ServletAdapterContentGenerator.createContent(ServletAdapterContentGenerator.java:88)
           [exec] at org.pentaho.platform.web.servlet.GenericServlet.doGet(GenericServlet.java:261)
           [exec] at org.pentaho.platform.web.servlet.GenericServlet.doPost(GenericServlet.java:80)
           [exec] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
           [exec] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           [exec] at org.pentaho.platform.web.http.filters.PentahoWebContextFilter.doFilter(PentahoWebContextFilter.java:102)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           [exec] at org.pentaho.platform.web.http.filters.PentahoRequestContextFilter.doFilter(PentahoRequestContextFilter.java:84)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
           [exec] at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
           [exec] at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
           [exec] at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.pentaho.platform.web.http.security.SecurityStartupFilter.doFilter(SecurityStartupFilter.java:103)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
           [exec] at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.pentaho.platform.web.http.security.RequestParameterAuthenticationFilter.doFilter(RequestParameterAuthenticationFilter.java:169)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174)
           [exec] at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:278)
           [exec] at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
           [exec] at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.pentaho.platform.web.http.security.HttpSessionReuseDetectionFilter.doFilter(HttpSessionReuseDetectionFilter.java:134)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
           [exec] at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
           [exec] at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
           [exec] at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
           [exec] at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
           [exec] at org.springframework.security.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:99)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           [exec] at org.pentaho.platform.web.http.filters.SystemStatusFilter.doFilter(SystemStatusFilter.java:60)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           [exec] at org.pentaho.platform.web.http.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:113)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           [exec] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           [exec] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
           [exec] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           [exec] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
           [exec] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           [exec] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           [exec] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           [exec] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
           [exec] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
           [exec] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
           [exec] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
           [exec] at java.lang.Thread.run(Thread.java:662)
           [exec] Caused by: java.lang.NullPointerException
           [exec] at mondrian.calc.CalcWriter.visitChild(CalcWriter.java:45)
           [exec] at mondrian.calc.CalcWriter.visitCalc(CalcWriter.java:78)
           [exec] at mondrian.calc.impl.AbstractCalc.accept(AbstractCalc.java:70)
           [exec] at mondrian.calc.CalcWriter.visitChild(CalcWriter.java:45)
           [exec] at mondrian.calc.CalcWriter.visitCalc(CalcWriter.java:78)
           [exec] at mondrian.calc.impl.AbstractCalc.accept(AbstractCalc.java:70)
           [exec] at mondrian.calc.CalcWriter.visitChild(CalcWriter.java:45)
           [exec] at mondrian.calc.CalcWriter.visitCalc(CalcWriter.java:78)
           [exec] at mondrian.calc.impl.AbstractCalc.accept(AbstractCalc.java:70)
           [exec] at mondrian.calc.CalcWriter.visitChild(CalcWriter.java:45)
           [exec] at mondrian.calc.CalcWriter.visitCalc(CalcWriter.java:78)
           [exec] at mondrian.calc.impl.AbstractCalc.accept(AbstractCalc.java:70)
           [exec] at mondrian.olap.Query.explain(Query.java:619)
           [exec] at mondrian.olap4j.MondrianOlap4jCellSet.close(MondrianOlap4jCellSet.java:267)
           [exec] at mondrian.olap4j.MondrianOlap4jStatement.close(MondrianOlap4jStatement.java:144)
           [exec] at org.saiku.olap.query.MdxQuery.execute(MdxQuery.java:129)
           [exec] at org.saiku.service.olap.OlapQueryService.execute(OlapQueryService.java:210)
           [exec] ... 87 more

        Activity

        Hide
        Pedro Alves added a comment -
        While digging more into this issue, I found that it's during olap4j close stmt.close(), while profiling the query.

        I traced it down to a bug in UdfResolver.java, where the Calc isn't set to the apropriate Calc[] element:

        diff --git a/src/main/mondrian/olap/fun/UdfResolver.java b/src/main/mondrian/olap/fun/UdfResolver.java
        index f331a1f..f85874c 100644
        --- a/src/main/mondrian/olap/fun/UdfResolver.java
        +++ b/src/main/mondrian/olap/fun/UdfResolver.java
        @@ -143,6 +143,7 @@ public class UdfResolver implements Resolver {
                             arg,
                             castType(arg.getType(), parameterCategories[i]),
                             ResultStyle.ANY_LIST);
        + calcs[i] = calc;
                         final Calc scalarCalc = compiler.compileScalar(arg, true);
                         final ListCalc listCalc;
                         final IterCalc iterCalc;
        Show
        Pedro Alves added a comment - While digging more into this issue, I found that it's during olap4j close stmt.close(), while profiling the query. I traced it down to a bug in UdfResolver.java, where the Calc isn't set to the apropriate Calc[] element: diff --git a/src/main/mondrian/olap/fun/UdfResolver.java b/src/main/mondrian/olap/fun/UdfResolver.java index f331a1f..f85874c 100644 --- a/src/main/mondrian/olap/fun/UdfResolver.java +++ b/src/main/mondrian/olap/fun/UdfResolver.java @@ -143,6 +143,7 @@ public class UdfResolver implements Resolver {                      arg,                      castType(arg.getType(), parameterCategories[i]),                      ResultStyle.ANY_LIST); + calcs[i] = calc;                  final Calc scalarCalc = compiler.compileScalar(arg, true);                  final ListCalc listCalc;                  final IterCalc iterCalc;
        Hide
        Julian Hyde added a comment -
        Fixed in https://github.com/pentaho/mondrian/commit/d3248e64e30f8d4bd4ca345619e09416090aecda

        Bug only occurs if profiling is enabled (the "mondrian.profile" logger). Bug only occurs with a UDF that has at least one argument and occurs on a query axis (not in a formula). I believe the query has to be executed via olap4j, but I may be wrong.
        Show
        Julian Hyde added a comment - Fixed in https://github.com/pentaho/mondrian/commit/d3248e64e30f8d4bd4ca345619e09416090aecda Bug only occurs if profiling is enabled (the "mondrian.profile" logger). Bug only occurs with a UDF that has at least one argument and occurs on a query axis (not in a formula). I believe the query has to be executed via olap4j, but I may be wrong.

          People

          • Assignee:
            Unassigned User
            Reporter:
            Pedro Alves
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: