1. 程式人生 > >解決kylin查詢報錯:org.apache.kylin.rest.exception.InternalErrorException

解決kylin查詢報錯:org.apache.kylin.rest.exception.InternalErrorException

name tex ada dha from 異常 bstr sca lap

報錯信息:

2017-06-26 20:06:58,925 ERROR [Query 12e9c054-760c-4615-9699-b1f06724c9b6-328] service.QueryService:372 : Exception when execute sql
java.lang.NullPointerException
        at org.apache.kylin.metadata.project.ProjectL2Cache.loadCache(ProjectL2Cache.java:193)
        at org.apache.kylin.metadata.project.ProjectL2Cache.getCache(ProjectL2Cache.java:
167) at org.apache.kylin.metadata.project.ProjectL2Cache.listExposedTables(ProjectL2Cache.java:84) at org.apache.kylin.metadata.project.ProjectManager.listExposedTables(ProjectManager.java:409) at org.apache.kylin.query.schema.OLAPSchemaFactory.createTempOLAPJson(OLAPSchemaFactory.java:
83) at org.apache.kylin.rest.service.CacheService.getOLAPDataSource(CacheService.java:159) at org.apache.kylin.rest.service.QueryService.execute(QueryService.java:526) at org.apache.kylin.rest.service.QueryService.queryWithSqlMassage(QueryService.java:452) at org.apache.kylin.rest.service.QueryService.query(QueryService.java:
151) at org.apache.kylin.rest.service.QueryService.doQueryWithCache(QueryService.java:354) at org.apache.kylin.rest.controller.QueryController.query(QueryController.java:69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
==========================[QUERY]===============================
Query Id: 12e9c054-760c-4615-9699-b1f06724c9b6
SQL: select VISIT_TYPE, count(*) from  xxdb.xxtable group by VISIT_TYPE
LIMIT 50000
User: ADMIN
Success: true
Duration: 0.0
Project: energon_dm
Realization Names: []
Cuboid Ids: []
Total scan count: 0
Result row count: 0
Accept Partial: true
Is Partial Result: false
Hit Exception Cache: false
Storage cache used: false
Message: null
==========================[QUERY]===============================
2017-06-26 20:06:58,926 ERROR [http-bio-7070-exec-6] controller.BasicController:44 : 
org.apache.kylin.rest.exception.InternalErrorException
        at org.apache.kylin.rest.service.QueryService.doQueryWithCache(QueryService.java:389)
        at org.apache.kylin.rest.controller.QueryController.query(QueryController.java:69)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:853)

解決過程:

根據報錯信息排查源碼:

技術分享

193行pi不為空,那就只能是pi.getExtFilters()為空,查看對應的meta數據,此字段果然為null。正常情況下此字段沒值時應該是個空數組,改為空數組後解決。原來異常meta是用戶自己生成通過後臺程序傳入kylin的。

技術分享

ps: 上面代碼位於類org.apache.kylin.metadata.project.ProjectL2Cache中,這個類對應的就是Meta中的一個project:

技術分享

解決kylin查詢報錯:org.apache.kylin.rest.exception.InternalErrorException