daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest Nov 6th, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Create test hql file.
  2.  
  3.  
  4.  
  5. test.hql:
  6.  
  7.  select 1 c1, '${YEAR}' tab;  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. Login to beeline
  15.  
  16.  
  17.  
  18. and  call hql script with YEAR as parameter
  19.  
  20.  
  21.  
  22. set hivevar:YEAR=2018;  
  23. !run test.hql  
  24.  
  25.  
  26.  
  27.  
  28. >>>  select 1 c1, '${YEAR}' tab;
  29.  
  30. INFO  : Compiling command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df): select 1 c1, '2018' tab
  31.  
  32. INFO  : Semantic Analysis Completed
  33.  
  34. INFO  : Returning Hive schema: Schema(fieldSchemas:[FieldSchema(name:c1, type:int, comment:null), FieldSchema(name:tab, type:string, comment:null)], properties:null)
  35.  
  36. INFO  : Completed compiling command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df); Time taken: 0.402 seconds
  37.  
  38. INFO  : Executing command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df): select 1 c1, '2018' tab
  39.  
  40. INFO  : Completed executing command(queryId=hive_20181023160101_d745c766-9491-43c9-af03-a2d99e8c91df); Time taken: 0.01 seconds
  41.  
  42. INFO  : OK
  43.  
  44. +-----+-------+--+
  45.  
  46. | c1  |  tab  |
  47.  
  48. +-----+-------+--+
  49.  
  50. | 1   | 2018  |
  51.  
  52. +-----+-------+--+
  53.  
  54. 1 row selected (24.101 seconds)
  55.  
  56.  
  57.  
  58.  
  59.  
  60. Option 2
  61.  
  62.  
  63.  
  64. beeline -u 'jdbc:hive2://bigdataplatform-uat.nam.nsroot.net:10000/;principal=hive/bigdataplatf
  65.  
  66. orm-uat.nam.nsroot.net@CTIP.NAM.NSROOT.NET;ssl=true;#to_table=eq_exec_detail_sf' -f gen_par_ins.sql
  67.  
  68.  
  69.  
  70. Inside gen_par_ins.sql use it like this:
  71.  
  72.  
  73.  
  74. Select trd_date from gfocnnsd_standardization.${to_table} LIMIT 10;
  75.  
  76.  
  77.  
  78.  
  79.  
  80. Option 3
  81.  
  82.  
  83.  
  84.  
  85.  
  86. 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"
  87.  
  88.  
  89.  
  90. Inside gen_par_ins.sql use it like this:
  91.  
  92.  
  93.  
  94. Select trd_date from gfocnnsd_standardization.${from_table} LIMIT 10;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top