0

hello friends i have written a hive query to get the count number as a variable. I will use this variable to update a column. But this query doesn't function well. It always give a Syntax error: ")" unexpected. Can anybody help me regarding this error? Here is my query- select count(tank_items_id) AS count_tank_items from master_data_assortment.tank_items_actual where item_type = 'shop_offer'; Thank you. Regards Mirish

M. T.
  • 33
  • 1
  • 7
  • this query is correct -> "select count(tank_items_id) AS count_tank_items from master_data_assortment.tank_items_actual where item_type = 'shop_offer';" are you sure you are getting Syntax error for this query – Nirmal Ram Nov 28 '16 at 12:33
  • @Nirmal, first of all thanks for reply. yes I have tried the same query and getting this error. I have searched everywhere and I found no solution. i really don't understand whats wrong with this query. – M. T. Nov 28 '16 at 12:40
  • can you post the full error – Nirmal Ram Nov 28 '16 at 12:41
  • $ select count(tank_items_id) AS count_tank_items from master_data_assortment.tank_items_actual where item_type = 'shop_offer'; sh: 7: Syntax error: "(" unexpected – M. T. Nov 28 '16 at 12:43

1 Answers1

0

try running as hive -e "select count(tank_items_id) AS count_tank_items from master_data_assortment.tank_items_actual where item_type = 'shop_offer';"

you should run in hive prompt not in cli

Nirmal Ram
  • 1,180
  • 2
  • 9
  • 18
  • yes i got my error. I was not in hive environment. I got an intiger value Now the query works fine. But my next step is to use this value to update column. So I have written a query-update meta_statistics.tank_items set shop_offers_actual_before = select count(tank_items_id) as count_tank_items from master_data_assortment.tank_items_actual where item_type = 'shop_offer' where t_stamp = '2016-11-21 14:57:13'; It gives ths error: FAILED: ParseException line 3:1 cannot recognize input near 'select' 'count' '(' in expression specification – M. T. Nov 28 '16 at 13:42
  • i think you can't update like that. check this http://stackoverflow.com/questions/6200871/update-set-option-in-hive – Nirmal Ram Nov 28 '16 at 13:51
  • Thanks Nirmal, I will go through it. – M. T. Nov 28 '16 at 13:56