本文共 4354 字,大约阅读时间需要 14 分钟。
网上没有找到Apache Kylin 2.3相关的样子,只好参考Apache Kylin 1.x 相关例子,但是运行报错。只好自己慢慢排查,下面做个记录。
select sum(price) as total_price from kylin_sales kswhere ks.part_dt between '2013-12-01' and '2013-12-31'
select sum(price) as total_price from kylin_sales kswhere ks.part_dt between '2013-12-01' and '2013-12-31' and ks.region = 'Shanghai'
错误信息
From line 2, column 63 to line 2, column 68: Column 'REGION' not found in table 'KS' while executing SQL: "select sum(price) as total_price from kylin_sales ks where ks.part_dt between '2013-12-01' and '2013-12-31' and ks.region = 'Shanghai'"
查看日志
[root@node1 logs]# vi kylin.log
Message: From line 2, column 81 to line 2, column 86: Column 'REGION' not found in table 'KYLIN_SALES'while executing SQL: "select sum(price) as total_price from kylin_sales where kylin_sales.part_dt between '2013-12-01' and '2013-12-31' and kylin_sales.region = 'Shanghai' LIMIT 50000"==========================[QUERY]===============================2018-05-31 09:17:44,366 ERROR [http-bio-7070-exec-1] controller.BasicController:61 :org.apache.kylin.rest.exception.InternalErrorException: From line 2, column 81 to line 2, column 86: Column 'REGION' not found in table 'KYLIN_SALES'while executing SQL: "select sum(price) as total_price from kylin_sales where kylin_sales.part_dt between '2013-12-01' and '2013-12-31' and kylin_sales.region = 'Shanghai' LIMIT 50000" at org.apache.kylin.rest.service.QueryService.doQueryWithCache(QueryService.java:474) at org.apache.kylin.rest.service.QueryService.doQueryWithCache(QueryService.java:390) at org.apache.kylin.rest.controller.QueryController.query(QueryController.java:86) at sun.reflect.GeneratedMethodAccessor178.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
通过日志分析可知,kylin_sales数据表不存在region字段。
查看表结构,确实没有region字段,已经更名为ops_regionhive> desc kylin_sales ;OKtrans_id bigint part_dt date Order Date lstg_format_name string Order Transaction Typeleaf_categ_id bigint Category ID lstg_site_id int Site ID slr_segment_cd smallint price decimal(19,4) Order Price item_count bigint Number of Purchased Goodsseller_id bigint Seller ID buyer_id bigint Buyer ID ops_user_id string System User ID ops_region string System User Region Time taken: 1.693 seconds, Fetched: 12 row(s)hive>
重新执行
select sum(price) as total_price from kylin_sales kswhere ks.part_dt between '2013-12-01' and '2013-12-31' and ks.ops_region = 'Shanghai'
其他例子
select count(distinct seller_id) as total_sellers from kylin_sales
select seller_id, sum(price) as total_price from kylin_sales group by seller_id order by sum(price) desc
select count(*) as order_amount from kylin_sales where lstg_site_id = 0