如何解决:ParseException:输入'FROM'不匹配,期望<EOF>(行87,位置4)

时间:2019-08-08 17:27:54

标签: sql apache-spark

我正在运行一个任务,以将数据加载到表中,一切似乎都很好,但是我不断收到错误消息:

select 
aa.source as source
,aa.Opportunity as Opportunity
,concat(substring(aa.create_date,1,4),'-',substring(aa.create_date,5,2),'-',substring(aa.create_date,7,2),'T',substring(aa.create_time,1,2),':',substring(aa.create_time,3,2),':',substring(aa.create_time,5,2),'.000Z') as Create_Date
,concat(substring(aa.submit_date,1,4),'-',substring(aa.submit_date,5,2),'-',substring(aa.submit_date,7,2),'T',substring(aa.submit_time,1,2),':',substring(aa.submit_time,3,2),':',substring(aa.submit_time,5,2),'+8:00') as Submit_Date
,aa.Bid_Reference_Number as Bid_Reference_Number
,aa.Bid_Reference_Number_Item as Bid_Reference_Number_Item
,aa.Solution_ID as Solution_ID
,aa.Config_ID  as Config_ID
,aa.LeROM_ID   as LeROM_ID
,concat(substring(aa.contract_start_date,1,4),'-',substring(aa.contract_start_date,5,2),'-',substring(aa.contract_start_date,7,2),'T00:00:00.000Z') as frontend_contract_start_date
,concat(substring(aa.Contract_Start_Date_in_Quotation,1,4),'-',substring(aa.Contract_Start_Date_in_Quotation,5,2),'-',substring(aa.Contract_Start_Date_in_Quotation,7,2),'T',substring(aa.zstrttime,1,2),':',substring(aa.zstrttime,3,2),':',substring(aa.zstrttime,5,2),'+8:00')as frontend_contract_start_date_in_quotation  --时间可以需要将 20170404  转2017-04-04 
,concat(substring(aa.Contract_End_Date_in_Quotation,1,4),'-',substring(aa.Contract_End_Date_in_Quotation,5,2),'-',substring(aa.Contract_End_Date_in_Quotation,7,2),'T',substring(aa.zendtime,1,2),':',substring(aa.zendtime,3,2),':',substring(aa.zendtime,5,2),'+8:00') as frontend_contract_end_date_in_quotation  --可以   
,aa.Contract_ID as Contract_ID
,aa.Contract_Item as Contract_Item
,aa.Contract_Status    as Contract_Status
,null as Backend_Contract_Start_Date
,null as Backend_Contract_Start_Date_in_Quotation
,null as Backend_Contract_End_Date_in_Quotation
,null as Backend_Contract_ID
,null as Backend_Contract_Item
,null as Backend_Contract_Status   
,aa.Quote_Description   as Quote_Description
,aa.Quotation_Transaction_Type as Quotation_Transaction_Type
,aa.Quotation_Transaction_Type_Medium_Name as Quotation_Transaction_Type_Medium_Name
,aa.Product_ID_Medium_Name   as Product_ID_Medium_Name
,aa.Product_ID_Key      as Product_ID_Key
,aa.Product_ID  as Product_ID
,aa.Product_Description as Product_Description
,aa.Quotation_Quantity  as Quotation_Quantity
,aa.Currency   as Currency
,aa.web_Price  as web_Price
,aa.Web_price_in_USD    as Web_price_in_USD
,aa.Channel_Price as Channel_Price
,aa.Channel_Price_in_USD as Channel_Price_in_USD
,aa.Quote_Price_or_Discount  as Quote_Price_or_Discount
,aa.Quote_Price_or_Discount_in_USD as Quote_Price_or_Discount_in_USD
,aa.Standard_Price      as Standard_Price
,aa.Standard_Price_in_USD    as Standard_Price_in_USD
,aa.Bid_Price  as bid_Price
,aa.Bid_Price_in_USD   as bid_Price_in_USD 
,aa.TMC as TMC
,aa.TMC_in_USD as TMC_in_USD
,aa.Net_Value  as Net_Value
,aa.Net_Value_in_USD as Net_Value_in_USD
,null as net_price 
,null as net_price_in_usd  
,aa.Actual_Revenue      as Actual_Revenue
,aa.Actual_Revenue_in_USD  as Actual_Revenue_in_USD
,null as margin_np_percent   
,null as margin_usd  
,null as total_margin_usd  
,null as total_margin_usd_in_usd   
,null as margin_np_in_usd     
,aa.GP  as GP
,aa.gp_in_usd  as gp_in_usd
,concat(Cast(cast(GP/CASE WHEN (case when aa.Actual_Revenue is null then 0 else aa.Actual_Revenue end)=0 OR Actual_Revenue = 0 THEN 1 ELSE (case when aa.Actual_Revenue is null then 0 else aa.Actual_Revenue end) END*100 as decimal(18,2)) as string),'%') AS GP_percentage      
,concat(round(((1-(aa.Bid_Price/CASE WHEN (case when aa.Web_Price is null then 0 else aa.Web_Price end)=0 OR aa.Web_Price = 0 THEN 1 ELSE (case when aa.Web_Price is null then 0 else aa.Web_Price end)END))*100),2),'%') AS DOL      
,aa.Bid_Status_Changed_on   as Bid_Status_Changed_on 
,aa.Bid_Status  as Bid_Status
,aa.Bid_Status_Long_Name as Bid_Status_Long_Name
,concat(substring(aa.date_approved,1,4),'-',substring(aa.date_approved,5,2),'-',substring(aa.date_approved,7,2),'T',substring(aa.approved_time,1,2),':',substring(aa.approved_time,3,2),':',substring(aa.approved_time,5,2),'.000Z') as Date_Approved
,aa.Approving_Status     as Approving_Status
,aa.Approving_Status_Long_Name as Approving_Status_Long_Name
,aa.Approval_Result    as Approval_Result 
,aa.Approval_Comment    as Approval_Comment 
,aa.Comment_Special    as Comment_Special 
,aa.Last_Pricer_Status  as Last_Pricer_Status
,aa.Last_Pricer_Status_Long_Name as Last_Pricer_Status_Long_Name
,aa.Sold_To    as Sold_To
,aa.Sold_To_Long_Name  as Sold_To_Long_Name
,ZBPLI_SR.nielsen_id as end_customer_Nielson_ID 
,aa.End_Customer as End_Customer
,aa.End_Customer_Long_Name   as End_Customer_Long_Name
,aa.Sales_Org  as Sales_Org
,aa.CRM_Sales_Org_Name  as CRM_Sales_Org_Name
,aa.Distribution_Channel as Distribution_Channel
,aa.Distribution_Channel_Name as Distribution_Channel_Name
,aa.User_Name  as create_by
,aa.Bid_Approver_First_Name   as Bid_Approver_First_Name
,aa.Bid_Approver_Last_Name   as Bid_Approver_Last_Name
,aa.Sales_Rep  as Sales_Rep
,aa.Sales_Rep_First_Name as Sales_Rep_First_Name
,aa.Sales_Rep_Last_Name  as Sales_Rep_Last_Name
,aa.Sales_Rep_Description    as Sales_Rep_Description 
,aa.Re_Bid    as Re_Bid 
,aa.Indirect_SBO as Indirect_SBO
,aa.SALESOFFCIE as SALESOFFCIE
,aa.SALES_OFFICE_DESCRIPTION as SALES_OFFICE_DESCRIPTION
,aa.Sub_Geo    as Sub_Geo
,aa.GEO as GEO
,aa.COUNTRY    as COUNTRY
,case when aa.Sales_Org in ('TH10' ,'ID90' ,'TW10','BR10') then  case when aa.Create_Date<20170101 then null else case when (aa.prodh1=7 or aa.prodh2='5EPG') then 'DCG' else null end end else aa.DCG_FLAG end as DCG_FLAG  
,aa.Original_Req_Price  as Original_Req_Price
,aa.Original_Req_Price_in_USD as Original_Req_Price_in_USD
,aa.Approved_Price      as Approved_Price
,aa.Approved_Price_in_USD as Approved_Price_in_USD
,null as apttus_config2_linetype 
,null as Approval_Level
,null as brand 
,null as apttus_qpconfig_configurationfinalizeddate 
,null as configurationfinalizeddate
,null as Feasibility
,null as FULFILLMENT_Method
,null as DEAL_REG
,null as PROPOSAL_PRESENTED_DATE
,null as Account_owner
,null as Account_name
,null as normal_path
,null as CTO_flag
,null as Custom_Model_for_MTM_only
,null as RPQ
,null as New_Custom_PN
,null as Product_Type
,'ThinkServer' as ThinkServer 
,'feasibility_approval_required' as feasibility_approval_required
,null as productgroupcode
,null as quotation_key_name
,null as quotation_key_frontend_contract_no
,null as quotation_key_backend_contract_no
,null as approvalrequest_key_Apttus_QPApprov_ProposalId
,null as productconfiguration_key_Apttus_QPConfig_Proposald   
,null as productconfiguration_key_apttus_config2_productconfiguration_id
,null as productconfiguration_key_id
,null as lineitem_key_Apttus_Config2_configurationId   
,null as lineitem_key_Name
,null as lineitem_key_Apttus_Config2_ProductId
,null as proposallineitem_key_Apttus_QPConfig_DerivedFromId
,null as pricingcontract_key_contract_number
,'' as sub_type
,'' as `gtn%`
from 
proj_sbtt.T1 aa
left join
proj_sbtt.bw_ms_zoozbplil_odl ZBPLI_SR
ON aa.End_Customer=ZBPLI_SR.ZBPLI
  

org.apache.spark.sql.catalyst.parser.ParseException: mismatched input 'FROM' expecting <EOF>(line 87, pos 4)

这是针对Spark sql的,以前没有问题

0 个答案:

没有答案