1

I am writing logic in a bash script which will run hive queries and will give the result of certain validations. I need add the result in the error table from the same bash script.

Is there any bash command to insert rows into a hive table from bash script?

zealous
  • 7,336
  • 4
  • 16
  • 36
Any
  • 21
  • 1
  • Is there a reason you could not have the bash script run a python script that does the heavy lifting? Some may 'bash' me for this, but I'd rather write Python than bash, any day! – LightCC Jul 15 '20 at 01:35

2 Answers2

0

it's butter to rewrite your code in Python or : use a python script that gets a query as input, and insert this query in the Hive table, you will run the python script from the bash script

like that

python python_script.py query

in the Python script, you will get the query like that

import sys
query=sys.argv[1]
HichamDz38
  • 94
  • 7
0

Call hive -e "insert statement " and pass parameters to the insert statement:

# some variables

#numeric variable
error_code=400

#string variable
error_desc="not found"

#insert into hive table    
hive -e "insert into table error_table values ('some static value', ${error_code}, '${error_description}' )"

You can make a function and use it with parameters

See also this answer about parameters passing: https://stackoverflow.com/a/56963448/2700344

leftjoin
  • 36,950
  • 8
  • 57
  • 116