zeppelin 初使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_34233802/article/details/70853121

下载:
http://mirror.bit.edu.cn/apache/zeppelin/zeppelin-0.7.1/zeppelin-0.7.1-bin-all.tgz
解压:
运行:
bin/zeppelin-daemon.sh start
有 start status restart stop等几种
打开:
http://localhost:8080/ 默认8080
这里写图片描述
点击create new note 可创立一个新的用于工作的notebook,点击notebook名称即可进入。

点击右上角,可以通过interpreter 创立一个解释器
这里写图片描述
如图创立一个新的presto,编辑相关的连接信息
(Zeppelin支持sql,shell,sh,elasticsearch,flink,livy等各种连接方式)
这里写图片描述

在notobook中通过 %presto的方式调用
如下:
%presto
select * from table

通过ds> dsselectfromtablewhereds> {ds} (日期输入加引号)
通过如下方式实现下拉框输入
select * from table where category=${分类=’发现’,’发现’|’精品’|’热门’}
这里写图片描述

%presto
select a.ds as "日期",a.category as "分类",a.module as "模块",d.dau as DAU,d.category_uv as "分类点击人数" ,a."点击次数",a."点击人数",f."开始下载次数", b."下载次数",b."下载人数",concat(cast(round(100.0*b."下载次数"/d.category_uv,2 ) as varchar), '%') as "安装转化率" from
((select ds,category,category_id,module,module_id,count(did) as "点击次数" , count(distinct (did)) as "点击人数" 
from xydb.xyzs_dd_mobile_act_action_detail_xydb where action_type=1 and (sub_action_type=1 or sub_action_type= 2) and  (ds between ${ds} and ${ds1})  and category=${分类='发现','发现'|'精品'|'热门'} group by ds,category,module, category_id,module_id) a
inner join
(select ds,category,category_id,module,module_id,count(did) as "下载次数" , count(distinct (did)) as "下载人数" 
from xydb.xyzs_dd_mobile_act_action_detail_xydb where action_type=2 group by ds,category,module,category_id,module_id) b
on a.ds=b.ds and a.category=b.category and a.module=b.module and a.category_id=b.category_id
and a.module_id=b.module_id
) 
inner join
(select ds,category,module, count(did) as "开始下载次数" from  xydb.xyzs_dd_mobile_act_action_detail_xydb where action_type =3 group by ds,category, module   order by ds,category)  as f
on a.ds=f.ds and a.category=f.category and a.module=f.module 

left OUTER JOIN 
(select cast(element_at(dim_map,'module_id') as bigint) as module_id, cast(element_at(dim_map,'category_id') as bigint) as category_id,element_at(metrics_map,'dau') as dau,element_at(metrics_map,'category_uv') as category_uv,ds from xydb.xyzs_vd_mobile_report_xydb where  element_at(dim_map,'category_id') is not Null  group by ds,element_at(dim_map,'category_id'),element_at(dim_map,'module_id'),element_at(metrics_map,'dau'),element_at(metrics_map,'category_uv')
) d 
on  ((d."ds" = a."ds") AND (d."category_id" = "a"."category_id") AND (d."module_id" = "a"."module_id"))  
order by a.ds,a.category,a.module  --汇总表

这里写图片描述

就是探探路

猜你喜欢

转载自blog.csdn.net/sinat_34233802/article/details/70853121
今日推荐