美文网首页
2020-04-02:hive的with..as.. 例子

2020-04-02:hive的with..as.. 例子

作者: 烂笔头2020 | 来源:发表于2020-04-02 17:22 被阅读0次

    with as 的作用就是建立一张临时的中间表,可以提高hivesql的查询性能,另外要注意的是中间表只能使用一次。
    例子:

    with vod_pv as (
            from gdfs.vod_asset_20200401 as a inner join gdfs.vod_20200401 as b on a.asset_id=b.asset_id
            select b.current_user as current_user,b.client_type as client_type,b.region as region,a.asset_id as asset_id,a.asset_name as asset_name,b.provider_id as provider_id,b.category_id as category_id,b.product_info as product_info
    )
    select client_type,region,asset_id,asset_name,provider_id,category_id,product_info,count(asset_id) as pv_num from vod_pv group by client_type,region,asset_id,asset_name,provider_id,category_id,product_info;
    
    

    可以直接在中间表进行查询

    相关文章

      网友评论

          本文标题:2020-04-02:hive的with..as.. 例子

          本文链接:https://www.haomeiwen.com/subject/lzzxphtx.html