一、定义数据源
### --- 定义数据源
~~~ 定义数据源
~~~ 加载数据
~~~ 查看加载的数据
![](https://i-blog.csdnimg.cn/blog_migrate/ed2d3630c497edd2df04a82c9ac15532.png)
![](https://i-blog.csdnimg.cn/blog_migrate/94358058530fbecae5a48b1065e42418.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2fe1213af39933afe026df38d259723f.png)
二、定义model
### --- 定义model
~~~ 定义model
~~~ 定义分区
![](https://i-blog.csdnimg.cn/blog_migrate/e7707e9fe244a501540d7f2a0b2b4c43.png)
![](https://i-blog.csdnimg.cn/blog_migrate/89d2152b780f359de6d11cf09177e771.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a5782decaf352d5af3d7b51c5c6ffc1.png)
![](https://i-blog.csdnimg.cn/blog_migrate/84394abcdd1908c0d2f2b218b094bbba.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1a4975a17e63df3beadebdaebf258d92.png)
![](https://i-blog.csdnimg.cn/blog_migrate/83bb8771bcd44f75e3b2aa6112ca591b.png)
三、定义cube
### --- 定义cube
~~~ 定义cube
~~~ 定义维度
~~~ 措施
~~~ Refresh Setting——>后面保持默认
![](https://i-blog.csdnimg.cn/blog_migrate/6aad322ad0b49e98e8a4901f12597fab.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c479a59ad323fcb317c89144802af281.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6f5f535cbd2cdcacc2cbdffd5b33cd70.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c71ab2251b48b1f6ac9f3635fea173bf.png)
![](https://i-blog.csdnimg.cn/blog_migrate/fbe502d78c3832b8e688901942d4266d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/807957f91dee63ecdf36fca229ea140f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e08ec71d6d7dee5a57f8a3681eb3e8f6.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b3234056d1a82872e855104bbc6ccf8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7a3eb9f6a3832f5a42fee1de060e0ee4.png)
四、构造第三个时间段cubecube
### --- 构造第三个时间段cubecube
~~~ # 构造三个时间段cube
~~~ # 选择时间段:
~~~ 第一个cube时间段:2021-10-01~2021-10-02
~~~ 第二个cube时间段:2021-10-02~2021-10-03
~~~ 第三个cube时间段:2021-10-03~2021-10-04
~~~ # 查看构建状态
~~~ # 查看对应的Segment:查看增量构建Cube对应的Segment
![](https://i-blog.csdnimg.cn/blog_migrate/8d0b4f1df4abe6a9e6594bf2320433b5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1f25a410babb70dc69a9b3b1959ca4cb.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e43459a9da62e32f6f2fe2fd67e3f328.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c5eae97baf5ec7c2bb738bf4fa3eb4fd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8a1568504155e77d93bf83fbfe6c9089.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5896668f4c146cb77051410e731c6354.png)
五、SQL查询
### --- 执行SQL查询语句
### --- SQL查询结果
~~~ # SQL语句一:
select t1.dt,
t2.regionname,
sum(t1.price) as total_money,
sum(t1.amount) as total_amount,
max(t1.price) as total_money,
min(t1.amount) as total_amount
from dw_sales1 t1 join dim_region t2 on t1.regionid = t2.regionid group by t1.dt, t2.regionname order by dt
~~~ # SQL语句二:
select
t1.dt,
t2.regionid,
t2.regionname,
t3.productid,
t3.productname,
sum(t1.price) as total_money,
sum(t1.amount) as total_amount
from dw_sales1 t1 inner join dim_region t2 on t1.regionid = t2.regionid inner join dim_product t3 on t1.productid = t3.productid group by
t1.dt,
t2.regionid,
t2.regionname,
t3.productid,
t3.productname
order by
t1.dt,
t2.regionname,
t3.productname
![](https://i-blog.csdnimg.cn/blog_migrate/f6ee63be57014bdc2c5b48d1ddba8076.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9c0d2b459a7647e9297f96a91f7a0cfe.png)