Hadoop 如何编写配置单元UDF

Hadoop 如何编写配置单元UDF,hadoop,mapreduce,hive,hiveql,hive-udf,Hadoop,Mapreduce,Hive,Hiveql,Hive Udf,我对如何使用UDF感到非常困惑。是否可以用UDF替换下面的bash脚本功能 #!/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_t

我对如何使用UDF感到非常困惑。是否可以用UDF替换下面的bash脚本功能

#!/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
请帮忙!!我见过如何反转字符串或更改大小写的UDF,但我不知道如何为这种重复使用查询结果的条件情况编写配置单元UDF


有没有其他更好的方法来处理此类查询流?

根据我的说法,您可以使用配置单元UDF在配置单元中启用某些sql函数,但不能使用这些函数来放置类似PL-sql的东西。 所以对于您的问题,您可以使用Spark SQL,这是我使用过的更好的方法