一、Azkaban的补充
1、动态参数传递
nodes:
- name: jobC
type: command
config:
command: echo "This is job C"
dependsOn:
- embedded_flow
- name: embedded_flow
type: flow
config:
prop: value
dt: ${data}
nodes:
- name: jobB
type: command
config:
command: echo "This is job B ${prop}"
dependsOn:
- jobA
- name: jobA
type: command
config:
command: echo "This is job A ${dt}"
2、定时任务
二、SuperSet实战
当第二天再次进入superset的时候,进不去,这个时候,你隐约觉得昨天没有关。
先进入superset环境:
conda activate superset
在后台杀死进程,再开启:
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9
gunicorn -w 1 -t 120 -b bigdata01:8787 "superset.app:create_app()"
实战前的环境准备:
需要数据:
可以执行 superset_demo.sql
让你的superset与mysql建立连接:
主要的是数据库连接的语句的写法:
mysql://root:123456@bigdata01/superset_demo?charset=utf8
如果你连接不上:
说明是没有数据库驱动:
conda install mysqlclient
接着需要重启superset:
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9
gunicorn -w 1 -t 120 -b bigdata01:8787 "superset.app:create_app()"
如果报连接异常,可以更换下面的数据库连接的url:
先下载:
pip install mysql-connector-python
再连接:
mysql+mysqlconnector://root:123456@bigdata01/superset_demo?charset=utf8
案例一:统计不同性别的人数
编写SQL语句:
SELECT
gender,
count(1) as total
from t_user
group by gender
选择完成会,不会自动的出图表的,需要点击 【Run】
以上不完美,原因是性别不是汉字,需要重新的编写SQL:
select
case when gender='1' then '男'
when gender ='0' then '女'
else '妖'
end as gender ,
count(1) as total
from t_user group by gender;
第二个案例:统计每日订单总额(趋势图)
SQL:
select sum(price) as total , str_to_date(date1,'%Y-%m-%d') date1 from dm_sales group by date1;
第三个案例:根据日期,渠道,统计订单总额(双环图)
select sum(price) as total, date1,channelname
from dm_sales
group by date1,channelname;
第四个案例:根据日期,区域,渠道,产品,统计订单总额(多环图)
select sum(price) as total, date1,channelname
from dm_sales
group by date1,channelname;
第五个案例:根据日期以及区域,统计销售额(透视图)
SQL语句:
select str_to_date(date1,'%Y-%m-%d') date1,regionname,sum(amount) as total_amount ,sum(price) as total
from dm_sales
group by date1,regionname;
此处需要将字符串类型转换为日期类型
三、面板的作用:
新建一个面板,就是一个空白页,我们可以将图表放在这个空白页上面。