0

I am so confused with how to use UDFS.Is it possible to replace below bash script functionality with UDFs ?

#!/bin/bash

 src_count_q="use db;select count(*) from config_table where table_nm="test_source";"
 src_count=$(hive -e $src_count_q)

 trg_count_q="use db;select count(*) from config_table where table_nm="test_target";"
 trg_count=$(hive -e $trg_count_q)

 if ["$src_count" = "trg_count"];
 then
   $(hive -e "use db;select * from test_target;")
 fi

Please help !! I have seen UDFs for how to reverse string or change case.But I am not able to figure out how to write HIVE UDF for these kind of conditional cases where we reuse the query result.

Is there any other better way to handle these kind of query flows?

user2895589
  • 1,010
  • 4
  • 20
  • 33

1 Answers1

0

According to me you can use HIVE UDFs to enable some sql function in hive but you can not use these to put PL-SQL like things. So for your question you can use Spark-SQL is a better way which I have used.

ankitbeohar90
  • 109
  • 13