您的位置:首页 > 业界新闻

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

2015-08-14 13:26 806 查看
订单宽表

#!/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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: