订单宽表
#!/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_descwhere dt='"${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_goodswhere dt='"${DT}"') b
on (a.order_id = b.order_id)
join (select * fromitqsc.ods_b2c_orders_descwhere dt='"${DT}"') c
on (a.order_id = c.order_id);
"
echo "${SQL}"
hive –e "$SQL"