Hive returns a non specific error : FAILED: SemanticException java.lang.reflect.UndeclaredThrowableException - hadoop

I have the following query in HIVE, but it doesn't work
SELECT
newcust.dt , aspen.Probe , newcust.direction , aspen.VLan , sum(newcust.npacket), sum(newcust.nbyte), sum(newcust.nbytetcp), sum(newcust.nbyteudp), sum(newcust.byte_unknown), sum(newcust.pack_unknown), sum(newcust.byte_web), sum(newcust.pack_web), sum(newcust.byte_webapp), sum(newcust.pack_webapp), sum(newcust.byte_residential), sum(newcust.pack_residential), sum(newcust.byte_download), sum(newcust.pack_download), sum(newcust.byte_news), sum(newcust.pack_news), sum(newcust.byte_mail), sum(newcust.pack_mail), sum(newcust.byte_db), sum(newcust.pack_db), sum(newcust.byte_routing), sum(newcust.pack_routing), sum(newcust.byte_encrypted), sum(newcust.pack_encrypted), sum(newcust.byte_office), sum(newcust.pack_office), sum(newcust.byte_vpn), sum(newcust.pack_vpn), sum(newcust.byte_tunneling), sum(newcust.pack_tunneling), sum(newcust.byte_others), sum(newcust.pack_others), sum(newcust.byte_remoteaccess), sum(newcust.pack_remoteaccess), sum(newcust.byte_streaming), sum(newcust.pack_streaming) , sum(newcust.byte_chat), sum(newcust.pack_chat), sum(newcust.byte_voip), sum(newcust.pack_voip), aspen.CustomerName, aspen.General_NetworkPriority, aspen.SLA_CIR, aspen.SLA_EIR
FROM
newcust INNER JOIN aspen ON( aspen.Probe = newcust.numsonde AND aspen.VLan = substring(newcust.name1,1,instr(newcust.name1, '_')-1) )
WHERE
newcust.numsonde = '1'
AND newcust.direction = '0'
AND newcust.dt LIKE '2012-01-20-%%%%'
AND COALESCE(UNIX_TIMESTAMP(aspen.scd_end,'dd-MM-yyyy'),CAST(9999999999 AS BIGINT)) >= UNIX_TIMESTAMP(newcust.dt,'yyyy-MM-dd-HHmm')+cast((newcust.period * 360) as BIGINT)
AND UNIX_TIMESTAMP(aspen.scd_start,'dd-MM-yyyy') < UNIX_TIMESTAMP(newcust.dt,'yyyy-MM-dd-HHmm')+cast((newcust.period * 360) as BIGINT)
GROUP BY newcust.dt, aspen.Probe, newcust.direction, aspen.VLan, aspen.CustomerName, aspen.General_NetworkPriority, aspen.SLA_CIR, aspen.SLA_EIR, from_unixtime(UNIX_TIMESTAMP(newcust.dt,'yyyy-MM-dd-HHmm')+cast((newcust.period * 360) as BIGINT))
Hive returns the following error :
FAILED: SemanticException java.lang.reflect.UndeclaredThrowableException. But there is no other explaination about the root of the problem.
Do you think the query is invalid or is it another "deeper" issue?

Make sure you include all the fields which are there in the select clause are included in group by clause.

Related

ORA-00904: "S"."AIR_TIME": invalid identifier

Why does this code show invalid identifier when sum is used in distance and air_time column?
When sum is not used this statement process successfully but using sum I get error? I need to use sum for this statement.
MERGE INTO FACT_COMPANY_GROWTH F
USING (SELECT DISTINCT TIME_ID, FLIGHT_KEY, AEROPLANE_KEY, SUM(DISTANCE) AS TOTAL_DISTANCE, SUM(AIR_TIME) AS TOTAL_AIRTIME
FROM TRANSFORM_FLIGHT T
INNER JOIN TRANSFORM_AEROPLANE A
ON T.FK_AEROPLANE_KEY = A.AEROPLANE_KEY
INNER JOIN DIM_TIME D
ON D.YEAR = T.YEAR
AND D.MONTH = T.MONTH
GROUP BY TIME_ID, FLIGHT_KEY, AEROPLANE_KEY) S
ON (F.FK1_TIME_ID = S.TIME_ID
AND F.FK2_FLIGHT_KEY = S.FLIGHT_KEY
AND F.FK3_AEROPLANE_KEY = S.AEROPLANE_KEY
)
WHEN MATCHED THEN
UPDATE SET
F.TOTAL_AIRTIME = S.AIR_TIME,
F.TOTAL_DISTANCE = S.DISTANCE,
F.TOTAL_NO_OF_FLIGHTS = S.FLIGHT_KEY,
F.TOTAL_NO_OF_AEROPLANE = S.AEROPLANE_KEY
WHEN NOT MATCHED THEN
INSERT(FACT_ID, FK1_TIME_ID, FK2_FLIGHT_KEY, FK3_AEROPLANE_KEY, TOTAL_DISTANCE, TOTAL_AIRTIME, TOTAL_NO_OF_FLIGHTS, TOTAL_NO_OF_AEROPLANE)
VALUES
(NULL, S.TIME_ID, S.FLIGHT_KEY, S.AEROPLANE_KEY, S.DISTANCE, S.AIR_TIME, S.FLIGHT_KEY, S.AEROPLANE_KEY);
USING(
SELECT DISTINCT
TIME_ID,
FLIGHT_KEY,
AEROPLANE_KEY,
SUM(DISTANCE) AS TOTAL_DISTANCE,
SUM(AIR_TIME) AS TOTAL_AIRTIME
...) S
The problem is at UPDATE SET F.TOTAL_AIRTIME = S.AIR_TIME. There are 5 fields defined in S and none is named AIR_TIME.
UPDATE SET
F.TOTAL_AIRTIME = S.TOTAL_AIRTIME,
F.TOTAL_DISTANCE = S.TOTAL_DISTANCE,

SQLRPGLE & JSON_OBJECT CTE Statements -101 Error

This program compiles correctly, we are on V7R3 - but when running it receives an SQLCOD of -101 and an SQLSTATE code is 54011 which states: Too many columns were specified for a table, view, or table function. This is a very small JSON that is being created so I do not think that is the issue.
The RPGLE code:
dcl-s OutFile sqltype(dbclob_file);
xfil_tofile = '/ServiceID-REFCODJ.json';
Clear OutFile;
OutFile_Name = %TrimR(XFil_ToFile);
OutFile_NL = %Len(%TrimR(OutFile_Name));
OutFile_FO = IFSFileCreate;
OutFile_FO = IFSFileOverWrite;
exec sql
With elm (erpRef) as (select json_object
('ServiceID' VALUE trim(s.ServiceID),
'ERPReferenceID' VALUE trim(i.RefCod) )
FROM PADIMH I
INNER JOIN PADGUIDS G ON G.REFCOD = I.REFCOD
INNER JOIN PADSERV S ON S.GUID = G.GUID
WHERE G.XMLTYPE = 'Service')
, arr (arrDta) as (values json_array (
select erpRef from elm format json))
, erpReferences (refs) as ( select json_object ('erpReferences' :
arrDta Format json) from arr)
, headerData (hdrData) as (select json_object(
'InstanceName' : trim(Cntry) )
from padxmlhdr
where cntry = 'US')
VALUES (
select json_object('header' : hdrData format json,
'erpReferenceData' value refs format json)
from headerData, erpReferences )
INTO :OutFile;
Any help with this would be very much appreciated, this is our first attempt at creating JSON for sending and have not experienced this issue before.
Thanks,
John
I am sorry for the delay in getting back to this issue. It has been corrected, the issue was with the "values" statement.
This is the correct code needed to make it work correctly:
Select json_object('header' : hdrData format json,
'erpReferenceData' value refs format json)
INTO :OutFile
From headerData, erpReferences )

column ambiguously defined even though all the selected columns are prefixed, while creating view

CREATE OR REPLACE VIEW V_DU_NBO_CAMPAIGN
AS
SELECT PMM_UPSELL_CAMPAIGN.STATUS, PMM_UPSELL_CAMPAIGN.TEST_EPOCH, DU_NBO_CAMPAIGN.*, OFFER_MSG_OFFERMESSAGE.TEXT AS OFFER_MSG_OFFERMESSAGE, NULL AS AWARD_MSG, REMINDER_MSG_REMINDERMESSAGE.TEXT AS REMINDER_MSG_REMINDERMESSAGE, PMM_PROGRAM.BASE_TIMEZONE, PMM_UPSELL_CAMPAIGN.CAMPAIGN_TEMPLATE, PMM_UPSELL_CAMPAIGN.TASKS_SUBMITTED, PMM_UPSELL_CAMPAIGN.TASKS_EVALUATED, PMM_UPSELL_CAMPAIGN.TASKS_COMPLETED, PMM_UPSELL_CAMPAIGN.EMITS, PMM_UPSELL_CAMPAIGN.LAST_EVALUATION, PMM_UPSELL_CAMPAIGN.LAST_PREEVALUATION, PMM_UPSELL_CAMPAIGN.TARGET_LIST_JOB_STATUS, PMM_UPSELL_CAMPAIGN.TARGET_LIST_TYPE, PMM_UPSELL_CAMPAIGN.TARGET_LIST_ID, PMM_UPSELL_CAMPAIGN.PENDING_TIME, PMM_UPSELL_CAMPAIGN.STARTING_TIME, PMM_UPSELL_CAMPAIGN.OFFERING_TIME, PMM_UPSELL_CAMPAIGN.OPEN_TIME, PMM_UPSELL_CAMPAIGN.SUSPENDED_TIME, PMM_UPSELL_CAMPAIGN.COMPLETE_TIME, PMM_UPSELL_CAMPAIGN.FAILED_TIME, PMM_UPSELL_CAMPAIGN.KILLED_TIME, PMM_UPSELL_CAMPAIGN.LAST_UPDATE_TIME
FROM
DU_NBO_CAMPAIGN
LEFT JOIN
PMM_UPSELL_CAMPAIGN
ON PMM_UPSELL_CAMPAIGN.CAMPAIGNID = DU_NBO_CAMPAIGN.CAMPAIGNID
LEFT JOIN
PMM_PROGRAM
ON PMM_PROGRAM.PROGRAM_ID = DU_NBO_CAMPAIGN.PROGRAM_ID
LEFT JOIN
DU_NBO_CAMPAIGN_MSG OFFER_MSG_OFFERMESSAGE
ON DU_NBO_CAMPAIGN.PROGRAM_ID = OFFER_MSG_OFFERMESSAGE.PROGRAM_ID
AND DU_NBO_CAMPAIGN.CAMPAIGNID = OFFER_MSG_OFFERMESSAGE.CAMPAIGNID
AND PMM_PROGRAM.DEFAULT_LANGUAGE = OFFER_MSG_OFFERMESSAGE."LANGUAGE"
AND OFFER_MSG_OFFERMESSAGE.MESSAGEID = 'NBO_SMS_OFFER'
LEFT JOIN
DU_NBO_CAMPAIGN_MSG OFFER_MSG_OFFERMESSAGE
ON DU_NBO_CAMPAIGN.PROGRAM_ID = OFFER_MSG_OFFERMESSAGE.PROGRAM_ID
AND DU_NBO_CAMPAIGN.CAMPAIGNID = OFFER_MSG_OFFERMESSAGE.CAMPAIGNID
AND PMM_PROGRAM.DEFAULT_LANGUAGE = OFFER_MSG_OFFERMESSAGE."LANGUAGE"
AND OFFER_MSG_OFFERMESSAGE.MESSAGEID = 'NBO_SMS_AWARD'
LEFT JOIN
DU_NBO_CAMPAIGN_MSG REMINDER_MSG_REMINDERMESSAGE
ON DU_NBO_CAMPAIGN.PROGRAM_ID = REMINDER_MSG_REMINDERMESSAGE.PROGRAM_ID
AND DU_NBO_CAMPAIGN.CAMPAIGNID = REMINDER_MSG_REMINDERMESSAGE.CAMPAIGNID
AND PMM_PROGRAM.DEFAULT_LANGUAGE = REMINDER_MSG_REMINDERMESSAGE."LANGUAGE"
AND REMINDER_MSG_REMINDERMESSAGE.MESSAGEID = 'NBO_SMS_REMINDER'
ORDER BY DU_NBO_CAMPAIGN.SCHEDULED_DAY DESC, DU_NBO_CAMPAIGN.SCHEDULED_HOUR DESC, DU_NBO_CAMPAIGN.NAME ASC;
I get this error when running above in Sql Developer:-
Error at Command Line:1 Column:0
Error report:
SQL Error: ORA-00918: column ambiguously defined
00918. 00000 - "column ambiguously defined"

Syntax Error: Token Join at Position 760 when importing SQL into Discoverer 11g

I wrote the query (below) in PL/SQL Developer for a client and would like to import it into Oracle Discoverer Desktop 11g so the report is self-serve. The query works perfectly in PL/SQL but when I go to import it into Discoverer, I get the following errors: "Error: Syntax error: token JOIN at position 760. Error: Parse stopped due to fatal errors."
Can anyone tell me what these errors mean and how to resolve the issue?
Thanks!
Query:
Select eid.person_code, eid.last_name plnownr_lname, eid.first_name plnownr_fname, eid.birth_date plnownr_DOB, des.status_code, dun.unit_code, ect.last_name BenRecip_LNAME, ect.first_name BenRecip_fname, ect.birth_date BenRecip_DOB,decode(ect.relation,'00','Unknown','01','Spouse','02','Common-Law Spouse','03','Partner', '05','Daughter','06','Son','07','Step-Daughter','08','Step-Son','09', 'Granddaughter','11', 'Father','12','Mother', '20','Sister','21','Brother','24','Aunt','28','Nephew','29','Ex-spouse','31','Friend','43','Trust','50','User Defined','52','User Defined', '53','User Defined','54','User Defined',ect.relation) relation, bpn.description, bpn.plan_code, bend.premium_start_date, bend.premium_end_date
From p2k_hr_identities eid
Join p2k_hr_contacts ect on ect.eid_id = eid.id
Join p2k_be_benefit_recipients bbr on bbr.ect_id = ect.id
Join p2k_be_enrollments ben on ben.id = bbr.ben_id
Join p2k_be_plan_definitions bpn on bpn.id = ben.bpn_id
Join p2k_hr_employments eem on eem.eid_id = eid.id
and eem.termination_date is null
Join p2k_hr_assignments eas on eas.eem_id = eem.id
Join p2k_hr_assignment_details easd on easd.eas_id = eas.id
and easd.expiry = to_date('3999-12-31', 'yyyy-mm-dd')
Join p2k_cm_units dun on dun.id = easd.dun_id
Join p2k_be_enrollment_details bend on bend.ben_id = ben.id
and bend.premium_end_date = to_date('3999-12-31','yyyy-mm-dd')
and bend.premium_start_date != to_date('0001-01-01','yyyy-mm-dd')
Join p2k_cm_employment_statuses des on des.id = easd.des_id
and des.status_code not in ('TERMINATED', 'RETIRED')
Union
Select eid.person_code, eid.last_name plnownr_lname, eid.first_name eplnownr_fname, eid.birth_date plnownr_dob, des.status_code, dun.unit_code, eid.last_name BenRecip_lname, eid.first_name BenRecip_fname, eid.birth_date BenRecip_dob, 'Employee-NoRelation', bpn.description, bpn.plan_code, bend.premium_start_date, bend.premium_end_date
From p2k_hr_identities eid
Join p2k_hr_employments eem on eem.eid_id = eid.id
and eem.termination_date is null
Join p2k_be_enrollments ben on ben.eem_id = eem.id
Join p2k_be_plan_definitions bpn on bpn.id = ben.bpn_id
Join p2k_hr_assignments eas on eas.eem_id = eem.id
Join p2k_hr_assignment_details easd on easd.eas_id = eas.id
and easd.expiry = to_date('3999-12-31', 'yyyy-mm-dd')
Join p2k_cm_units dun on dun.id = easd.dun_id
Join p2k_be_enrollment_details bend on bend.ben_id = ben.id
and bend.premium_end_date = to_date('3999-12-31','yyyy-mm-dd')
and bend.premium_start_date != to_date('0001-01-01','yyyy-mm-dd')
Join p2k_cm_employment_statuses des on des.id = easd.des_id
and des.status_code not in ('TERMINATED', 'RETIRED')
Order by 2,3,5,6

Suppress ORA-01403: no data found excpetion

I have the following code
SELECT SUM(nvl(book_value,
0))
INTO v_balance
FROM account_details
WHERE currency = 'UGX';
--Write the balance away
SELECT SUM(nvl(book_value,
0))
INTO v_balance
FROM account_details
WHERE currency = 'USD';
--Write the balance away
Now the problem is, there might not be data in the table for that specific currency, but there might be data for the 'USD' currency. So basically I want to select the sum into my variable and if there is no data I want my stored proc to continue and not throw the 01403 exception.
I don't want to put every select into statement in a BEGIN EXCEPTION END block either, so is there some way I can suppress the exception and just leave the v_balance variable in an undefined (NULL) state without the need for exception blocks?
select nvl(balance,0)
into v_balance
from
(
select sum(nvl(book_value,0)) as balance
from account_details
where currency = 'UGX'
);
SELECT L1.PKCODE L1CD, L1.NAME L1N, L1.LVL L1LVL,
L2.PKCODE L2CD, L2.NAME L2N, L2.LVL L2LVL,
L5.PKCODE L5CD, L5.NAME L5N,
INFOTBLM.OPBAL ( L5.PKCODE, :PSTDT, :PSTUC, :PENUC, :PSTVT, :PENVT ) OPBAL,
INFOTBLM.DEBIT ( L5.PKCODE, :PSTDT,:PENDT, :PSTUC, :PENUC, :PSTVT, :PENVT ) AMNTDR,
INFOTBLM.CREDIT ( L5.PKCODE, :PSTDT,:PENDT, :PSTUC, :PENUC, :PSTVT, :PENVT ) AMNTCR
FROM FSLVL L1, FSLVL L2, FSMAST L5
WHERE L2.FKCODE = L1.PKCODE
AND L5.FKCODE = L2.PKCODE
AND L5.PKCODE Between :PSTCD AND NVL(:PENCD,:PSTCD)
GROUP BY L1.PKCODE , L1.NAME , L1.LVL ,
L2.PKCODE , L2.NAME , L2.LVL ,
L5.PKCODE , L5.NAME
ORDER BY L1.PKCODE, L2.PKCODE, L5.PKCODE

Resources