Creating Views in Hive with parameter

前端 未结 3 1945
清歌不尽
清歌不尽 2021-01-03 05:44

I have a table that contains rows belonging to various dates. I want to CREATE A VIEW which should give me the data based on the date

CREATE VIEW newusers
A         


        
3条回答
  •  执念已碎
    2021-01-03 05:52

    In the hive script, just replace the date with a variable:

    CREATE VIEW newusers
    AS
    SELECT DISTINCT T1.uuid
    FROM user_visit T1
    WHERE T1.firstSeen="${hiveconf:date}";
    

    Then give that variable a value when invoking hive:

    hive --hiveconf date=20140522 -f 'create_newusers_view.hql'
    

    Or just set it from within hive:

    set date=20140522;
    

提交回复
热议问题