互联网电商大数据环境 ——大数飓数据分析实践培训精华笔记(七)——电商核心业务知识之订单商品模块

来源:互联网 发布:fc2 最新域名设置 编辑:程序博客网 时间:2024/05/04 22:39

订单宽表


#!/bin/bash

#======

#dm_b2c_orders.sh    这里用shell来调

#订单宽表——两个表关联

#======

DT=`date -d  '-1 day'  "+%Y-%m-%d" `注意date  -d ‘-1 day’表示取前一天

或者sysdate=`date "+%Y-%m-%d"`脚本传参数法

if  [$1]; then

   DT=$1

fi

SQL="

insert overwrite tableitqsc.dm_b2c_orders partition (dt=' "${DT}" ')

select

a.order_id,

a.order_no,

a.order_date,

a.user_id,

a.user_name,

a.order_money,

a.order_type,

a.order_status,

a.pay_type,

a.pay_status,

a.order_source,

 

b.consignee,

b.area_id,

b.area_name,

b.address,

b.mobilephone,

b.telephone,

b.coupon_id,

b.coupon_money,

b.carriage_money,

b.create_time,

a.last_update_time,

'sysdate()' dw_date (取当前系统时间)

或者'${sysdate} ' dw_date(取当前系统时间)

from (select * from itqsc.ods_b2c_orderswheredt='"${DT}"')a

join (select * fromitqsc.ods_b2c_orders_descwheredt='"${DT}"') b

on (a.order_id = b.order_id)  limit 12;limit遏抑数据滚屏

"

echo  "${SQL}"

hive –e  "$SQL"



#!/bin/bash

#======

#dm_b2c_orders_goods.sh    这里用shell来调

#订单与商品宽表——三个表关联

#======

DT=`date -d  '-1 day'  "+%Y-%m-%d" `注意date  -d ‘-1 day’表示取前一天

或者sysdate=`date "+%Y-%m-%d"`脚本传参数法

if  [$1]; then

   DT=$1

fi

SQL="

insert overwrite tableitqsc.dm_b2c_orders_goods partition (dt=' "${DT}" ')

select

a.order_id,

b.goods_id,

b.cat_id,

b.cat_name,

b.size_id,

b.goods_price,

b.goods_amount,

a.order_no,

a.order_date,

a.user_id,

a.user_name,

a.order_money,

a.order_type,

a.order_status,

a.pay_type,

a.pay_status,

a.order_source,

c.coupon_id,

c.coupon_money,

c.carriage_money,

sysdate() dw_date (取当前系统时间)

from (select * from itqsc.ods_b2c_orderswheredt='"${DT}"')a

join (select * fromitqsc.ods_b2c_orders_goodswheredt='"${DT}"') b

on (a.order_id = b.order_id)

join (select * fromitqsc.ods_b2c_orders_descwheredt='"${DT}"') c

on (a.order_id = c.order_id);

"

echo  "${SQL}"

hive –e  "$SQL"




0 0
原创粉丝点击