使用LineageInfo分析hive sql中的表关系
org.apache.hadoop.hive.ql.tools.LineageInfo
public static void main(String[] args) throws IOException, ParseException, SemanticException { //String query = args[0]; //String query = "select a.* from a join (select * from b where id like '%哈哈%') c on a.id = c.id"; String query = "insert overwrite table youni_contact_name_his_temp2 " + "select a.*,b.type,b.kind1,b.kind3,b.keywords,b.match_type,b.male_rt,b.male_accuracyrate ,b.income " + "from youni_contact_name_his_temp a join (select type,kind1,kind3,keywords,match_type,male_rt,male_accuracyrate ,income " + "from youni_contact_name_type_dim where match_type='{data_desc}')b on 1=1 " + "where instr(a.user_name,b.keywords)>0"; LineageInfo lep = new LineageInfo(); lep.getLineageInfo(query); for (String tab : lep.getInputTableList()) { System.out.println("InputTable=" + tab); } for (String tab : lep.getOutputTableList()) { System.out.println("OutputTable=" + tab); } }
执行结果:
InputTable=youni_contact_name_his_temp InputTable=youni_contact_name_type_dim OutputTable=youni_contact_name_his_temp2
相关推荐
zlsdmx 2020-07-05
tugangkai 2020-07-04
archive 2020-07-30
成长之路 2020-07-28
eternityzzy 2020-07-19
taisenki 2020-07-05
tugangkai 2020-07-05
SignalDu 2020-07-05
tomson 2020-07-05
tomson 2020-07-05
Zhangdragonfly 2020-06-28
genshengxiao 2020-06-26
成长之路 2020-06-26
tomson 2020-06-26
蜗牛之窝 2020-06-26
成长之路 2020-06-25