欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Apache Kylin 2.3 样例分析

程序员文章站 2022-04-11 09:41:37
...

网上没有找到Apache Kylin 2.3相关的样子,只好参考Apache Kylin 1.x 相关例子,但是运行报错。只好自己慢慢排查,下面做个记录。

select sum(price) as total_price  from kylin_sales ks
where ks.part_dt between '2013-12-01' and '2013-12-31'

Apache Kylin 2.3 样例分析

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'

错误信息

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_region

hive> desc  kylin_sales ;
OK
trans_id                bigint                                      
part_dt                 date                    Order Date          
lstg_format_name        string                  Order Transaction Type
leaf_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 Goods
seller_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 ks
where ks.part_dt between '2013-12-01' and '2013-12-31' and ks.ops_region = 'Shanghai'

Apache Kylin 2.3 样例分析

其他例子

select count(distinct seller_id) as total_sellers from kylin_sales

Apache Kylin 2.3 样例分析

select seller_id, sum(price) as total_price from kylin_sales 
group by seller_id order by sum(price) desc

Apache Kylin 2.3 样例分析

select count(*) as order_amount from kylin_sales where lstg_site_id = 0

Apache Kylin 2.3 样例分析

相关标签: Kylin