问题描述: 通过Hive-exec解析HQL语句时,出现解析异常。
发现问题在解析set hive.vectorized.execution.enabled=false; 网上也没有搜索到解决方案。
并且该语句在HUE上执行是正常的。求大神指导
package hql;
import com.alibaba.druid.DbType;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.parser.SQLParserUtils;
import com.alibaba.druid.sql.parser.SQLStatementParser;
import org.apache.hadoop.hive.ql.parse.ParseException;
import org.apache.hadoop.hive.ql.parse.ParseUtils;
import org.springframework.util.Assert;
import java.util.List;
public class Parser {
public static void main(String[] args) throws ParseException {
String hql = "-- 目 标 表:[std.sp_ft_fmbn_write_off_detail_a] [核销明细]n" +
"-- 源 表 名:n" +
"-- [dv.sat_wangdai_pluton_zeus_acct_write_off_bill_4_l] n" +
"-- [dv.sat_wangdai_pluton_zeus_acct_write_off_bill_detail_4_l]n" +
"-- [dv.sat_wangdai_pluton_adam_acct_write_off_bill_4_l]n" +
"-- [dv.sat_wangdai_pluton_adam_acct_write_off_bill_detail_4_l]n" +
"-- [dv.sat_ft_pluton_zeus_acct_loan_bill]n" +
"-- [dv.sat_ft_pluton_zeus_pf_category_product]n" +
"-- [dv.sat_ft_pluton_zeus_acct_ious]n" +
"-- [dv.sat_ft_pluton_zeus_acct_five_classification]n" +
"-- [dv.sat_wangdai_pluton_zeus_pf_category_business]n" +
"-- 源表码值:n" +
"-- 加载策略: [03] (注,00:其他 01:覆盖,02:更新,03:追加,04:拉链)n" +
"-- 运行周期: [1] (注, 1:天,2:星期,3:旬,4:月,5:季,6:半年,7:年,00:其他)n" +
"-- 脚本功能: 核销明细n" +
"-- 创建时间: 2018-09-17n" +
"-- 文 件 名: sp_ft_fmbn_write_off_detail_a.hqln" +
"-- 作 者: " +
"-- 修改记录:n" +
"n" +
"n" +
"n" +
"INSERT INTO pdm.job_log_detail (data_date,tab_title,tab_name,job_step,job_time,job_info)n" +
"SELECT '2020-09-24','std','sp_ft_fmbn_write_off_detail_a','00',current_timestamp(),'start' ;n" +
"n" +
"--清空数据n" +
"TRUNCATE TABLE std.sp_ft_fmbn_write_off_detail_a ;n" +
"n" +
"n" +
"--创建临时表 std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_4_ln" +
"DROP TABLE IF EXISTS std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_4_l;n" +
"n" +
"n" +
"CREATE TEMPORARY table std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_4_l asn" +
"SELECT t.*n" +
" FROMn" +
" (n" +
" SELECT t01.*n" +
" ,row_number() over(partition by t01.hub_wangdai_pluton_zeus_acct_write_off_bill_4_l_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_wangdai_pluton_zeus_acct_write_off_bill_4_l as t01 WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
" AND t.sat_del_flag='0'n" +
";n" +
"n" +
"--创建临时表 std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_detail_4_ln" +
"DROP TABLE IF EXISTS std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_detail_4_l;n" +
"CREATE TEMPORARY table std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_detail_4_l asn" +
"SELECT t.write_off_bill_id,n" +
" sum(case when t.write_off_subject='PRI' then t.write_off_subject_amt else 0 end) pri_writeoff_amt,--本金n" +
"t sum(case when t.write_off_subject='INT' then t.write_off_subject_amt else 0 end) int_writeoff_amt,--利息n" +
"t sum(case when t.write_off_subject='PIN' then t.write_off_subject_amt else 0 end) pin_writeoff_amt--罚息n" +
" FROMn" +
" (n" +
" SELECT t01.*n" +
" ,row_number() over(partition by t01.hub_wangdai_pluton_zeus_acct_write_off_bill_detail_4_l_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_wangdai_pluton_zeus_acct_write_off_bill_detail_4_l as t01 WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
" AND t.sat_del_flag='0'n" +
" GROUP BY t.write_off_bill_idtn" +
";n" +
"n" +
"n" +
"--创建临时表 std.temp_ft_write_off_pluton_adam_acct_write_off_bill_4_ln" +
"DROP TABLE IF EXISTS std.temp_ft_write_off_pluton_adam_acct_write_off_bill_4_l;n" +
"CREATE TEMPORARY table std.temp_ft_write_off_pluton_adam_acct_write_off_bill_4_l asn" +
"SELECT t.*n" +
" FROMn" +
" (n" +
" SELECT t01.*n" +
" ,row_number() over(partition by t01.hub_wangdai_pluton_adam_acct_write_off_bill_4_l_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_wangdai_pluton_adam_acct_write_off_bill_4_l as t01 WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
" AND t.sat_del_flag='0'n" +
";n" +
"n" +
"--创建临时表 std.temp_ft_write_off_pluton_adam_acct_write_off_bill_detail_4_ln" +
"DROP TABLE IF EXISTS std.temp_ft_write_off_pluton_adam_acct_write_off_bill_detail_4_l;n" +
"CREATE TEMPORARY table std.temp_ft_write_off_pluton_adam_acct_write_off_bill_detail_4_l asn" +
"SELECT t.write_off_bill_id,n" +
" sum(case when t.write_off_subject='PRI' then t.write_off_subject_amt else 0 end) pri_writeoff_amt,--本金n" +
"t sum(case when t.write_off_subject='INT' then t.write_off_subject_amt else 0 end) int_writeoff_amt,--利息n" +
"t sum(case when t.write_off_subject='PIN' then t.write_off_subject_amt else 0 end) pin_writeoff_amt--罚息n" +
" FROMn" +
" (n" +
" SELECT t01.*n" +
" ,row_number() over(partition by t01.hub_wangdai_pluton_adam_acct_write_off_bill_detail_4_l_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_wangdai_pluton_adam_acct_write_off_bill_detail_4_l as t01 WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
" AND t.sat_del_flag='0'n" +
" GROUP BY t.write_off_bill_idtn" +
";n" +
"n" +
"--创建临时表 std.temp_ft_write_off_acct_acct_loan_billn" +
" DROP TABLE IF EXISTS std.temp_ft_write_off_acct_acct_loan_bill;n" +
" CREATE TEMPORARY table std.temp_ft_write_off_acct_acct_loan_bill asn" +
" SELECT t.*n" +
" FROM (n" +
" SELECT t01.*n" +
" ,row_number() over(partition by t01.hub_ft_pluton_zeus_acct_loan_bill_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_ft_pluton_zeus_acct_loan_bill as t01 WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
" ;n" +
" n" +
"--创建临时表 std.temp_ft_write_off_pf_category_productn" +
" DROP TABLE IF EXISTS std.temp_ft_write_off_pf_category_product;n" +
" CREATE TEMPORARY table std.temp_ft_write_off_pf_category_product asn" +
" SELECT t.*n" +
" FROM (SELECT t01.* ,row_number() over(partition by t01.hub_ft_pluton_zeus_pf_category_product_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_ft_pluton_zeus_pf_category_product as t01n" +
" WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
" ; n" +
" n" +
"--创建临时表 std.temp_ft_write_off_acct_iousn" +
"DROP TABLE IF EXISTS std.temp_ft_write_off_acct_ious;n" +
"CREATE TEMPORARY table std.temp_ft_write_off_acct_ious asn" +
"SELECT t.*n" +
" FROM (n" +
" SELECT t01.*n" +
" ,row_number() over(partition by t01.hub_ft_pluton_zeus_acct_ious_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_ft_pluton_zeus_acct_ious as t01 WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
"; n" +
"n" +
"--创建临时表 std.temp_ft_write_off_acct_five_classificationn" +
"DROP TABLE IF EXISTS std.temp_ft_write_off_acct_five_classification;n" +
"CREATE TEMPORARY table std.temp_ft_write_off_acct_five_classification asn" +
"SELECT t.*n" +
" FROM (n" +
" SELECT t01.*n" +
" ,row_number() over(partition by t01.hub_ft_pluton_zeus_acct_five_classification_key order by sat_load_dts desc) as rownn" +
" FROM dv.sat_ft_pluton_zeus_acct_five_classification as t01 WHERE sat_load_dts<='2020-09-24'n" +
" ) as tn" +
" WHERE t.rown=1n" +
";n" +
"n" +
"--创建临时表 std.temp_ft_write_off_pf_category_businessn" +
"DROP TABLE IF EXISTS std.temp_ft_write_off_pf_category_business;n" +
"CREATE TEMPORARY table std.temp_ft_write_off_pf_category_business asn" +
"SELECT t.*n" +
"FROM (select t01.* ,row_number() over(partition by t01.hub_wangdai_pluton_zeus_pf_category_business_key order by sat_load_dts desc) as rownn" +
"tt FROM dv.sat_wangdai_pluton_zeus_pf_category_business as t01n" +
"tt WHERE sat_load_dts<='2020-09-24'n" +
"t ) as tn" +
"WHERE t.rown=1n" +
";n" +
"n" +
"set hive.vectorized.execution.enabled=false;n" +
"n" +
"INSERT INTO std.sp_ft_fmbn_write_off_detail_an" +
"(n" +
" load_timen" +
" ,sp_load_dtsn" +
" ,busi_date --业务日期n" +
"t,serail_no --核销明细流水号n" +
"t,loanwriteoffid --贷款核销申请号n" +
"t,loan_id --借据号n" +
"t,mxkmbh --明细科目编号n" +
"t,mxkmmc --明细科目名称n" +
"t,five_class --五级分类n" +
"t,amt_all --全额核销贷款金额n" +
"t,amt_part --差额核销贷款金额n" +
"t,write_off_date --核销日期n" +
"t,write_off_time --核销时间n" +
"t,plan_date --还款计划状态n" +
"t,out_flg --非应计标识n" +
"t,write_off_amt --核销金额n" +
"t,write_off_prin_amt --本金核销金额n" +
"t,write_off_int_amt --利息核销金额n" +
"t,write_off_pnlt_amt --罚息核销金额n" +
"t,write_off_cmpd_amt --复利核销金额n" +
"t,write_off_fee_amt --费用核销金额n" +
"t,owner_write_off_amt --额n" +
"t,owner_write_off_prin_amt --金n" +
"t,owner_write_off_int_amt --息n" +
"t,owner_write_off_pnlt_amt --息n" +
"t,owner_write_off_cmpd_amt --n" +
"t,owner_write_off_fee_amt --n" +
"t,fund_write_off_amt --额n" +
"t,fund_write_off_prin_amt --本金n" +
"t,fund_write_off_int_amt --利息n" +
"t,fund_write_off_pnlt_amt --息n" +
"t,fund_write_off_cmpd_amt --利n" +
"t,fund_write_off_fee_amt --用n" +
"t,in_account_date --n" +
"t,product_no --号n" +
"t,fund_channel_no --号n" +
"t,bzh --注n" +
"t,channel_business_id --识n" +
")n" +
"SELECTn" +
" date_format(current_timestamp(),'yyyy-MM-dd HH:mm:ss') AS load_time -- 数n" +
" ,'2020-09-24' sp_load_dts --增n" +
" ,t01.write_off_date busi_date --业n" +
"t ,t01.in_request_id serail_no --核n" +
"t ,t01.loan_write_off_order_id loanwriteoffid --号n" +
"t ,t02.ious_id loan_id --号n" +
"t ,case when t03.ious_mark='1' then coalesce(t04.union_accounting_template_id,'')n" +
" else coalesce(t04.accounting_template_id,'')n" +
" end mxkmbh --号n" +
"t ,t04.accounting_template_name mxkmmc --称n" +
"t ,case when t05.five_classification='1' then 'FQ01'n" +
"ttt when t05.five_classification='2' then 'FQ02'n" +
"ttt when t05.five_classification='3' then 'FQ03'n" +
"ttt when t05.five_classification='4' then 'FQ04'n" +
"ttt when t05.five_classification='5' then 'FQ05'n" +
"ttt else ''n" +
"ttend five_class --类n" +
"t ,coalesce(t01.write_off_amt,'0') amt_all --额n" +
"t ,'0' amt_part --额n" +
"t ,regexp_replace(t01.write_off_date,'-','') write_off_date --期n" +
"t ,regexp_replace(substr(t01.create_date,12,8),':','') write_off_time --间n" +
"t ,'2' plan_date --态n" +
"t ,'1' out_flg --识n" +
"t ,coalesce(t01.write_off_amt,'0') write_off_amt --额n" +
"t ,coalesce(t06.pri_writeoff_amt,'0') write_off_prin_amt --额n" +
"t ,coalesce(t06.int_writeoff_amt,'0') write_off_int_amt --额n" +
"t ,coalesce(t06.pin_writeoff_amt,'0') write_off_pnlt_amt --额n" +
"t ,'0' write_off_cmpd_amt --额n" +
"t ,coalesce(t01.write_off_amt,'0') write_off_fee_amt --额n" +
"t ,case when t03.ious_mark='1' then coalesce(t01.write_off_amt,'0')-coalesce(t08.write_off_amt,'0')n" +
"t else coalesce(t01.write_off_amt,'0')n" +
"t end owner_write_off_amt --额n" +
"t ,case when t03.ious_mark='1' then coalesce(t06.pri_writeoff_amt,'0')-coalesce(t07.pri_writeoff_amt,'0')n" +
"t else coalesce(t06.pri_writeoff_amt,'0')n" +
"t end owner_write_off_prin_amt --金n" +
"t ,case when t03.ious_mark='1' then coalesce(t06.int_writeoff_amt,'0')-coalesce(t07.int_writeoff_amt,'0')n" +
"t else coalesce(t06.int_writeoff_amt,'0')n" +
"t end owner_write_off_int_amt --息n" +
"t ,case when t03.ious_mark='1' then coalesce(t06.pin_writeoff_amt,'0')-coalesce(t07.pin_writeoff_amt,'0')n" +
"t else coalesce(t06.pin_writeoff_amt,'0')n" +
"t end owner_write_off_pnlt_amt --息n" +
"t ,'0' owner_write_off_cmpd_amt --利n" +
"t ,case when t03.ious_mark='1' then coalesce(t01.write_off_amt,'0')-coalesce(t08.write_off_amt,'0')n" +
"t else coalesce(t01.write_off_amt,'0')n" +
"t end owner_write_off_fee_amt --用n" +
"t ,coalesce(t08.write_off_amt,'0') fund_write_off_amt --额n" +
"t ,coalesce(t07.pri_writeoff_amt,'0') fund_write_off_prin_amt --金n" +
"t ,coalesce(t07.int_writeoff_amt,'0') fund_write_off_int_amt --息n" +
"t ,coalesce(t07.pin_writeoff_amt,'0') fund_write_off_pnlt_amt --息n" +
"t ,'0' fund_write_off_cmpd_amt --利n" +
"t ,coalesce(t08.write_off_amt,'0') fund_write_off_fee_amt --用n" +
"t ,regexp_replace('2020-09-24','-','') in_account_date --期n" +
"t ,t09.business_definition_val product_no --号n" +
"t ,'0' fund_channel_no --号n" +
"t ,'' bzh --注n" +
"t ,'A05' channel_business_id --识n" +
" FROMn" +
" std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_4_l t01 n" +
" LEFT JOINn" +
" std.temp_ft_write_off_acct_acct_loan_bill t02n" +
" ONn" +
" t01.loan_bill_id=t02.loan_bill_idn" +
" LEFT JOINn" +
" std.temp_ft_write_off_acct_ious t03 n" +
"tONn" +
"t t02.ious_id=t03.ious_idn" +
" LEFT JOINn" +
" std.temp_ft_write_off_pf_category_product t04n" +
" ONn" +
" t03.product_classify_id=t04.product_classify_idn" +
" LEFT JOINn" +
" std.temp_ft_write_off_acct_five_classification t05n" +
" ONn" +
" t03.ious_id=t05.ious_idn" +
" LEFT JOINn" +
" std.temp_ft_write_off_pluton_zeus_acct_write_off_bill_detail_4_l t06n" +
"tONn" +
"t t01.write_off_bill_id=t06.write_off_bill_idn" +
" LEFT JOINn" +
" std.temp_ft_write_off_pluton_adam_acct_write_off_bill_detail_4_l t07n" +
"tONn" +
"t t01.write_off_bill_id=t07.write_off_bill_idn" +
" LEFT JOINn" +
" std.temp_ft_write_off_pluton_adam_acct_write_off_bill_4_l t08n" +
"tONn" +
"t t01.write_off_bill_id=t08.write_off_bill_idn" +
" LEFT JOINn" +
" (n" +
"tt SELECT product_classify_id,business_definition_valn" +
" FROM std.temp_ft_write_off_pf_category_businessn" +
" WHERE business_definition_name = 'BUSINESS_CODE'n" +
" ) t09n" +
" ONn" +
" t03.product_classify_id=t09.product_classify_idn" +
"n" +
";n" +
"n" +
"n" +
"n" +
"--件n" +
"INSERT OVERWRITE DIRECTORY '/user/etl/ctl/std/sp/ft/OK/2020-09-24/sp_ft_fmbn_write_off_detail_a' SELECT '';n" +
"n" +
"--日志记录n" +
"INSERT INTO pdm.job_log_detail (data_date,tab_title,tab_name,job_step,job_time,job_info)n" +
"SELECT '2020-09-24','std','sp_ft_fmbn_write_off_detail_a','99',current_timestamp(),'end';";
// SQLStatementParser sqlStatementParser = SQLParserUtils.createSQLStatementParser(hql, DbType.hive);
// List<SQLStatement> sqlStatements = SQLUtils.parseStatements(hql, DbType.mysql);
// Assert.state(sqlStatements.size() == 24,"解析错误");
String[] split = hql.split(";");
for(int i = 0; i < split.length; i++){
ParseUtils.parse(split[i]);
}
}
}