Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create test hql file.
- test.hql:
- select 1 c1, '${YEAR}' tab;
- Login to beeline
- and call hql script with YEAR as parameter
- set hivevar:YEAR=2018;
- !run test.hql
- >>> select 1 c1, '${YEAR}' tab;
- INFO : Compiling command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df): select 1 c1, '2018' tab
- INFO : Semantic Analysis Completed
- INFO : Returning Hive schema: Schema(fieldSchemas:[FieldSchema(name:c1, type:int, comment:null), FieldSchema(name:tab, type:string, comment:null)], properties:null)
- INFO : Completed compiling command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df); Time taken: 0.402 seconds
- INFO : Executing command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df): select 1 c1, '2018' tab
- INFO : Completed executing command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df); Time taken: 0.01 seconds
- INFO : OK
- +-----+-------+--+
- | c1 | tab |
- +-----+-------+--+
- | 1 | 2018 |
- +-----+-------+--+
- 1 row selected (24.101 seconds)
- Option 2
- beeline -u 'jdbc:hive2://bigdataplatform-uat.nam.nsroot.net:10000/;principal=hive/bigdataplatf
- orm-uat.nam.nsroot.net@CTIP.NAM.NSROOT.NET;ssl=true;#to_table=eq_exec_detail_sf' -f gen_par_ins.sql
- Inside gen_par_ins.sql use it like this:
- Select trd_date from gfocnnsd_standardization.${to_table} LIMIT 10;
- Option 3
- beeline -u 'jdbc:hive2://bigdataplatform-uat.nam.nsroot.net:10000/;principal=hive/bigdataplatform-uat.nam.nsroot.net@CTIP.NAM.NSROOT.NET;ssl=true;' -f gen_par_ins.sql --hivevar "from_table=eq_exec_detail_sf_tmp" --hivevar "to_table=eq_exec_detail_sf"
- Inside gen_par_ins.sql use it like this:
- Select trd_date from gfocnnsd_standardization.${from_table} LIMIT 10;
Add Comment
Please, Sign In to add comment