Way to speed up an insert with left outer join - insert

I am trying to figure out a way to speed up this query...as is it takes about 40 minutes.
Inserts new rows not existing in a table of a linked server.
INSERT INTO [remote.server.com].[DB].dbo.Table1( Id , Barcode , Name , Address , Address2 , City , State , Zip , Date , Text1 , Text2 , Text3 , Text4 , Text5 , Text6 , Text7 , Text8 , Text9 , Text10 )
SELECT s.Id , s.Barcode , s.Name , s.Address , s.Address2 , s.City , s.State , s.Zip , s.Date , s.Text1 , s.Text2 , s.Text3 , s.Text4 , s.Text5 , s.Text6 , s.Text7 , s.Text8 , s.Text9 , s.Text10
FROM LocalTable1 AS s LEFT OUTER JOIN [remote.server.com].[DB].dbo.Table1 AS d ON s.Id = d.Id AND s.Barcode = d.Barcode
WHERE d.Id IS NULL;
Any ideas? Thanks for the help.

Related

Using Cumulative and Percent Rank functions in my query

I'm working on this query and would like to use the cumulative distribution or percent rank function to provide me with cumulative distribution and the percent rank for field 'leads distribution'. however, it appears that when the decile value is populated it doesn't give me the right number for that decile for example the LeadGrouping record 'FLJeffersonCollateral' should have a decile of 1 but is showing a decile of 2. Can you help what am I doing wrong? Below is the query.
Select c.LeadGrouping
, c.StateID
, c.County
, c.Media_Type
, Sum(c.Leads) as 'Leads'
, Sum(isnull(c.CCPEnroll,0)) as 'CCPEnroll'
, c.CloseRate
--, row_number() over(partition by c.Field1 order by c.CloseRate desc) as line_number
, sum(mx.MaxLeads) as 'MaxLeads' --ALTER TO MAX LEADS OVERALL --sum(mx.MaxLeads)
, CONVERT(DECIMAL(10,10), isnull(Sum(c.leads),0) / convert(numeric, isnull(sum(mx.MaxLeads),0))) as 'LeadDistribution' --CONFIRM TOTAL SUMS TO 100%
, PERCENT_RANK () over (order by Convert (Decimal(10,10), (isnull(Sum(c.leads),0) / convert(numeric, isnull(sum(mx.MaxLeads),0))))) as 'percent rank'
From (Select 'A' as 'Field1'
, b.LeadGrouping
, b.StateID
, b.County
, b.Media_Type
, Sum(b.Leads) as 'Leads'
, Sum(b.CCPEnroll) as 'CCPEnroll'
, CONVERT(DECIMAL(5,2), isnull(Sum(b.CCPEnroll),0) / convert(numeric, isnull(Sum(b.Leads),0))) as 'CloseRate'
From (Select a.LeadGrouping
, a.StateID
, a.County
, a.Media_Type
, Sum(a.Lead) as 'Leads'
, Sum(a.CCPEnroll) as 'CCPEnroll'
From (Select distinct al.LeadID
, al.Interaction_ID
, al.createddate
, al.appointmentdate
, al.C2CExp
, Case When al.EnrollMonth is not null Then DateDiff(day, al.createddate, al.AppDate)
Else DateDiff(day, al.createddate, GETDATE()) End as 'LeadTenureInDays'
, Count(distinct i.interaction_id) as 'LeadInteractionCount'
, l.lead_interactionsource__c
, al.MarketID
, left(al.state_county_key,2) as 'StateID'
, al.County
, al.Media_Type
, al.SegmentName
, al.Correctcampaign
, c.name as 'CampaignName'
, c.lead_program__c
, l.lead_disposition__c
, al.CCPEnroll
, al.PDPEnroll
, al.AppDate
, al.EnrollMonth
, al.writingagentid
, p.ProducerType
, al.Lead
, case When f.fipscode is null Then 'Not In CCP Footprint'
When f.FIPSCode is not null Then 'In CCP Footprint'
else 'ERROR' End as 'Footprint'
, CONCAT(left(al.state_county_key,2),al.county, al.Media_Type) as 'LeadGrouping'
From rknow.dbo.allleadstemp2 al
Left Join rknow.dbo.campaign_sfdc_datalake c on al.correctcampaign = c.id
Left Join rknow.dbo.lead_sfdc_datalake l on al.leadid = l.id
Left Join rknow.dbo.producerstructure_datalake p on al.writingagentid = p.producerid and al.createddate >= p.effectivestartdate and al.createddate <= DateAdd(day, 1, p.effectiveenddate)
Left Join [RKnow].[rpt].[interaction] i on al.leadid = i.lead_id
Inner Join rknow.dbo.fipsspc f on al.fips = f.fipscode --2022 CCP County Level Footprint
Where al.C2CExp >= DateAdd(day,1,getdate())
and al.lead_type = 'ccp' --HD 12/04/2020: Added criteria filter to exclude CrossSell leads
Group by al.LeadID
, al.Interaction_ID
, al.C2CExp
, al.createddate
, al.MarketID
, al.state_county_key
, al.County
, al.Media_Type
, al.SegmentName
, al.Correctcampaign
, al.appointmentdate
, c.name
, c.lead_program__c
, l.lead_disposition__c
, al.CCPEnroll
, al.PDPEnroll
, al.EnrollMonth
, al.writingagentid
, p.ProducerType
, l.lead_interactionsource__c
, al.AppDate
, f.fipscode
, al.Lead) a
Group by a.LeadGrouping
, a.Media_Type
, a.StateID
, a.County) b
Group by b.LeadGrouping
, b.StateID
, b.County
, b.Media_Type) c
Left Join (Select distinct 'A' as 'Field1', sum(mx.lead) as 'MaxLeads'
From(Select distinct al.LeadID
, al.Interaction_ID
, al.createddate
, al.appointmentdate
, al.C2CExp
, Case When al.EnrollMonth is not null Then DateDiff(day, al.createddate, al.AppDate)
Else DateDiff(day, al.createddate, GETDATE()) End as 'LeadTenureInDays'
, Count(distinct i.interaction_id) as 'LeadInteractionCount'
, l.lead_interactionsource__c
, al.MarketID
, left(al.state_county_key,2) as 'StateID'
, al.County
, al.Media_Type
, al.SegmentName
, al.Correctcampaign
, c.name as 'CampaignName'
, c.lead_program__c
, l.lead_disposition__c
, al.CCPEnroll
, al.PDPEnroll
, al.AppDate
, al.EnrollMonth
, al.writingagentid
, p.ProducerType
, al.Lead
, case When f.fipscode is null Then 'Not In CCP Footprint'
When f.FIPSCode is not null Then 'In CCP Footprint'
else 'ERROR' End as 'Footprint'
, CONCAT(left(al.state_county_key,2),al.county, al.Media_Type) as 'LeadGrouping'
From rknow.dbo.allleadstemp2 al
Left Join rknow.dbo.campaign_sfdc_datalake c on al.correctcampaign = c.id
Left Join rknow.dbo.lead_sfdc_datalake l on al.leadid = l.id
Left Join rknow.dbo.producerstructure_datalake p on al.writingagentid = p.producerid and al.createddate >= p.effectivestartdate and al.createddate <= DateAdd(day, 1, p.effectiveenddate)
Left Join [RKnow].[rpt].[interaction] i on al.leadid = i.lead_id
Inner Join rknow.dbo.fipsspc f on al.fips = f.fipscode --2022 CCP County Level Footprint
Where al.C2CExp >= DateAdd(day,1,getdate())
and al.lead_type = 'ccp' --HD 12/04/2020: Added criteria filter to exclude CrossSell leads
Group by al.LeadID
, al.Interaction_ID
, al.C2CExp
, al.createddate
, al.MarketID
, al.state_county_key
, al.County
, al.Media_Type
, al.SegmentName
, al.Correctcampaign
, al.appointmentdate
, c.name
, c.lead_program__c
, l.lead_disposition__c
, al.CCPEnroll
, al.PDPEnroll
, al.EnrollMonth
, al.writingagentid
, p.ProducerType
, l.lead_interactionsource__c
, al.AppDate
, f.fipscode
, al.Lead) mx) mx on mx.Field1 = c.Field1
Group by c.LeadGrouping
, c.StateID
, c.County
, c.Media_Type
, c.CloseRate
, c.Field1

Hibernate and H2 no dialect mapping for jdbc type 0

Im running this Query via JpaRepository on MSSQL Server and it works fine
SELECT TOP(8) * FROM (
SELECT distinct a.id as source_id
, null as f_name
, null as m_name
, null as last_name
, null as full_name
, a.name as business_name
, a.dba_name as dba_name
, ad.id as address_id
, ad.line_1 as address_line_1
, ad.city_town as city
, right(tr.code,2) as state
, ad.zip_postal_code as postal_code
, co.name as country_name
, a.national_tax_ident as id_number
, 'T' as id_number_type
, null as date_of_birth
, 'SuretyVP' as data_source_id
, 'AGENT' as role_id
, getdate() as cycle_date
, 299 as create_user_id
, getdate() as create_date
, null as update_date
, null as attention
, 'agency' as entity_name
from dbo.Agency a
inner join dbo.agency_address ag on a.id = ag.agency_id
inner join dbo.address ad on ad.id = ag.address_id
inner join [AdminDB].[dbo].[countries] co
on ad.country_id = co.id
inner join [AdminDB].[dbo].[territories] tr
on ad.state_province_territory_id = tr.id
Where a.ofac_processed_ind = 0
AND ag.address_type_id = 2
AND ag.exp_date is null
AND a.agency_status_id = 1
UNION ALL
SELECT distinct c.id as source_id
, c.first_name as f_name
, c.middle_name as m_name
, c.last_name as last_name
, null as full_name
, null as business_name
, null as dba_name
, null as address_id
, null as address_line_1
, null as city
, null as state
, null as postal_code
, 'United States' as country_name
, null as id_number
, null as id_number_type
, null as date_of_birth
, 'SuretyVP' as data_source_id
, 'AGENT' as role_id
, getdate() as cycle_date
, 299 as create_user_id
, getdate() as create_date
, null as update_date
, null as attention,
'contact' as entity_name
from dbo.Contact c
inner join dbo.Agency_contact ac on c.id = ac.contact_id
inner join dbo.agency a on ac.agency_id = a.id
Where c.ofac_processed_ind = 0
AND a.agency_status_id = 1
ANd c.exp_date is null
ANd ac.exp_date is null
AND ac.contact_role_type_id = 12) as data
But when I try to Run integration test with this query against H2 DB I have the following error
No dialect mapping for jdbc type 0
Here is my H2 DB config spring.datasource.url=jdbc:h2:mem:test:SAMINTEGERATIONTEST;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MSSQLServer
I saw similar topics, but unfortunately didn't find solution for my problem.
I would be very grateful for any advice.Thank you!
null as full_name, null as date_of_birth, null as update_date, and null as attention don't have a data type in both first and second queries, therefore UNION ALL also can't determine the data type. H2 by itself doesn't care about this situation and assumes that these columns have a fake NULL data type and can have only NULL value. But your persistence libraries don't like it.
The simplest solution is to add a CAST to all these columns in one of the queries (or in both of them, if you wish, it doesn't matter):
CAST(null AS VARCHAR) as full_name,
…
CAST(null AS DATE) as date_of_birth,
…

Re-writing a view that uses condition join [OR]

I have this view that is performing really bad, and the problem is its build on joins that use or conditions
I have tried re-writing this for the past 2 days, using CTE and UNION but the result is incorrect
Maybe you guys can help, just few ideas how to do it, because I am completely lost.
CREATE VIEW [dbo].[V_Amazon_Listings]
AS
SELECT
DISTINCT
ISNULL(a.MerchantId, b.MerchantId) AS MerchantId
, ISNULL(a.SKU, b.[seller-sku]) AS SKU
, ISNULL(a.Quantity, 0) AS NONFBAQTY
, ISNULL(b.[Quantity Available], 0) AS FBAQTY
, ISNULL(a.[ASIN], b.[ASIN]) AS [ASIN]
, CASE
WHEN salePrices.SKU IS NOT NULL THEN ISNULL(CONVERT(DECIMAL(18, 2), (salePrices.SalePrice * vamm.USDConversionRate)), 9999)
ELSE ISNULL(CONVERT(DECIMAL(18, 2), (a.Price * vamm.USDConversionRate)), 9999)
END AS Price
, CASE ISNULL(a.Quantity, 0)
WHEN 0 THEN ISNULL(b.[Quantity Available], 0)
ELSE ISNULL(a.Quantity, 0)
END AS Quantity
--a.ReportRequestId,
, CASE WHEN ISNULL(a.Quantity, 0) = 0 AND ISNULL(b.[Quantity Available], 0) > 0 THEN 1
ELSE 0
END AS IsFBAed
, CASE WHEN c.[seller-sku] IS NULL THEN 0
ELSE 1
END AS IsRestricted--,
--a.ReportRequestId RegReportRequestID, b.ReportRequestId FBAReportRequestID, c.ReportRequestID CancReportRequestID
FROM
(
SELECT
ID
, MerchantId
, SKU
, [ASIN]
, Price
, CASE Quantity
WHEN '' THEN 0
ELSE Quantity
END AS Quantity
, ReportRequestId
FROM dbo.Amazon_Listings_Raw WITH (NOLOCK)
WHERE RIGHT(SKU,4) <> '__ON'
AND ReportRequestId IN
(
SELECT
MAX(ReportRequestId)
FROM v_Amazon_Listings_Raw WITH (NOLOCK)
GROUP BY MerchantId
)
) AS a
FULL JOIN
(
SELECT
b.ID
, b.MerchantId
, b.[seller-sku]
, b.[fulfillment-channel-sku]
, b.[ASIN]
, b.[condition-type]
, b.[Warehouse-Condition-code]
, b.[Quantity Available]
, b.ReportRequestId
FROM dbo.[Amazon_FBA_Listings_Raw] AS b WITH (NOLOCK)
WHERE
ReportRequestId IN
(
SELECT
MAX(ReportRequestId)
FROM [v_Amazon_FBA_Listings_Raw] WITH (NOLOCK)
GROUP BY MerchantId
)
AND [Warehouse-Condition-code] = 'Sellable'
) AS b
ON a.MerchantId = b.MerchantId
AND a.SKU = b.[seller-sku]
LEFT JOIN
(
SELECT
ID
, MerchantId
, [item-name]
, [item-description]
, [seller-sku]
, Price
, Quantity
, [image-url]
, [item-is-marketplace]
, [product-id-type]
, [zshop-shipping-fee]
, [item-note]
, [item-condition]
, [zshop-category1]
, [zshop-browse-path]
, [zshop-storefront-feature]
, asin1
, asin2
, asin3
, [will-ship-internationally]
, [expedited-shipping]
, [zshop-boldface]
, [product-id]
, ReportRequestId
FROM dbo.[Amazon_Cancelled_Listings_Raw] WITH (NOLOCK)
WHERE RIGHT([seller-sku],4) <> '__ON'
AND ReportRequestId IN
(
SELECT MAX(ReportRequestId)
FROM [v_Amazon_Cancelled_Listings_Raw] WITH (NOLOCK)
GROUP BY MerchantId
)
) AS c
ON (a.MerchantId = c.MerchantId OR b.MerchantId = c.MerchantId)
AND (b.[seller-sku] = c.[seller-sku] OR a.SKU = c.[seller-sku])
INNER JOIN V_Amazon_Marketplace_Merchants vamm
ON (a.MerchantId = vamm.MerchantID OR b.MerchantId = vamm.MerchantId)
LEFT JOIN AmazonOurPrices salePrices WITH (NOLOCK)
ON vamm.MerchantId = salePrices.MerchantId
AND a.SKU = salePrices.SKU
AND salePrices.SalePrice <> salePrices.RegularPrice
This is what I have come up with, its runs really fast 20 seconds,
but the data is off, not sure what I am missing or doing wrong.
any help would be glady appreciated
CREATE VIEW AMZ_NOTUSED_12_22_2017
as
WITH A ( MerchantID,Sku,Asin,Price,Quantity, [Seller-Sku],SalePrice,USDConversionRate,salePricesSKU,[Quantity Available])
AS
(
SELECT a.MerchantId,a.SKU,a.ASIN,a.Price,a.Quantity, c.[seller-sku],salePrices.SalePrice,vamm.USDConversionRate,salePrices.SKU AS salePricesSKU,'' [Quantity Available]
FROM
(
SELECT
ID
, MerchantId
, SKU
, [ASIN]
, Price
, CASE Quantity
WHEN '' THEN 0
ELSE Quantity
END AS Quantity
, ReportRequestId
FROM dbo.Amazon_Listings_Raw WITH (NOLOCK)
WHERE RIGHT(SKU,4) <> '__ON'
AND ReportRequestId IN
(
SELECT
MAX(ReportRequestId)
FROM v_Amazon_Listings_Raw WITH (NOLOCK)
GROUP BY MerchantId
)
) AS a
LEFT JOIN
(
SELECT
ID
, MerchantId
, [item-name]
, [item-description]
, [seller-sku]
, Price
, Quantity
, [image-url]
, [item-is-marketplace]
, [product-id-type]
, [zshop-shipping-fee]
, [item-note]
, [item-condition]
, [zshop-category1]
, [zshop-browse-path]
, [zshop-storefront-feature]
, asin1
, asin2
, asin3
, [will-ship-internationally]
, [expedited-shipping]
, [zshop-boldface]
, [product-id]
, ReportRequestId
FROM dbo.[Amazon_Cancelled_Listings_Raw] WITH (NOLOCK)
WHERE RIGHT([seller-sku],4) <> '__ON'
AND ReportRequestId IN
(
SELECT MAX(ReportRequestId)
FROM [v_Amazon_Cancelled_Listings_Raw] WITH (NOLOCK)
GROUP BY MerchantId
)
) AS c
ON a.MerchantId = c.MerchantId and a.SKU = c.[seller-sku]
INNER JOIN V_Amazon_Marketplace_Merchants vamm
ON a.MerchantId = vamm.MerchantID
LEFT JOIN AmazonOurPrices salePrices WITH (NOLOCK)
ON vamm.MerchantId = salePrices.MerchantId
AND a.SKU = salePrices.SKU
AND salePrices.SalePrice <> salePrices.RegularPrice
)
,
B AS
(
SELECT b.MerchantId,
b.[Seller-SKU] AS Sku,
b.ASIN,
c.Price,
c.quantity ,
c.[seller-sku],
salePrices.SalePrice,
vamm.USDConversionRate,
salePrices.SKU AS salePricesSKU,
b.[Quantity Available]
FROM
(
SELECT
b.ID
, b.MerchantId
, b.[seller-sku]
, b.[fulfillment-channel-sku]
, b.[ASIN]
, b.[condition-type]
, b.[Warehouse-Condition-code]
, b.[Quantity Available]
, b.ReportRequestId
FROM dbo.[Amazon_FBA_Listings_Raw] AS b WITH (NOLOCK)
WHERE
ReportRequestId IN
(
SELECT
MAX(ReportRequestId)
FROM [v_Amazon_FBA_Listings_Raw] WITH (NOLOCK)
GROUP BY MerchantId
)
AND [Warehouse-Condition-code] = 'Sellable'
) AS b
LEFT JOIN
(
SELECT
ID
, MerchantId
, [item-name]
, [item-description]
, [seller-sku]
, Price
, Quantity
, [image-url]
, [item-is-marketplace]
, [product-id-type]
, [zshop-shipping-fee]
, [item-note]
, [item-condition]
, [zshop-category1]
, [zshop-browse-path]
, [zshop-storefront-feature]
, asin1
, asin2
, asin3
, [will-ship-internationally]
, [expedited-shipping]
, [zshop-boldface]
, [product-id]
, ReportRequestId
FROM dbo.[Amazon_Cancelled_Listings_Raw] WITH (NOLOCK)
WHERE RIGHT([seller-sku],4) <> '__ON'
AND ReportRequestId IN
(
SELECT MAX(ReportRequestId)
FROM [v_Amazon_Cancelled_Listings_Raw] WITH (NOLOCK)
GROUP BY MerchantId
)
) AS c
ON
b.[seller-sku] = c.[seller-sku] and b.MerchantId = c.MerchantId
INNER JOIN V_Amazon_Marketplace_Merchants vamm
ON b.MerchantId = vamm.MerchantId
LEFT JOIN AmazonOurPrices salePrices WITH(NOLOCK)
ON vamm.MerchantId = salePrices.MerchantId
AND b.[Seller-SKU] = salePrices.SKU
AND salePrices.SalePrice <> salePrices.RegularPrice
)
SELECT
DISTINCT
a.MerchantId AS MerchantId
, a.SKU
, a.Quantity AS NONFBAQTY
, ISNULL(a.[Quantity Available],0) AS FBAQTY
, a.[ASIN] AS [ASIN]
, CASE
WHEN salePricesSKU IS NOT NULL THEN ISNULL(CONVERT(DECIMAL(18, 2), (SalePrice * USDConversionRate)), 9999)
ELSE ISNULL(CONVERT(DECIMAL(18, 2), (a.Price * USDConversionRate)), 9999)
END AS Price
, CASE ISNULL(a.Quantity, 0)
WHEN 0 THEN ISNULL(a.[Quantity Available], 0)
ELSE ISNULL(a.Quantity, 0)
END AS Quantity
, CASE WHEN ISNULL(a.Quantity, 0) = 0 AND ISNULL(a.[Quantity Available], 0) > 0 THEN 1
ELSE 0
END AS IsFBAed
, CASE WHEN a.[seller-sku] IS NULL THEN 0
ELSE 1
END AS IsRestricted
FROM
(
SELECT * FROM a
UNION
SELECT * FRom B
) a

What is the meaning of "unable to open iterator for an alias" in pig?

I was trying to use the union operator like as show below
uni_b = UNION A, B, C, D, E, F, G, H;
here all the relations A,B,C...H are having same schema
when ever I am using the dump operator, till 85% it running fine.. after that it is showing the following error..
ERROR 1066: Unable to open iterator for alias uni_b
what is this? where is the problem? how should I debug?
this is my pig script...
ip = load '/jee/jee_data.txt' USING PigStorage(',') as (id:Biginteger, fname:chararray , lname:chararray , board:chararray , eid:chararray , gender:chararray , math:double , phy:double , chem:double , jeem:double , jeep:double , jeec:double ,cat:chararray , dob:chararray);
todate_ip = foreach ip generate id, fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec , cat , ToDate(dob,'dd/MM/yyyy') as dob;
jnbresult1 = foreach todate_ip generate id, fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec, ROUND_TO(AVG(TOBAG( math , phy , chem )),3) as bresult, ROUND_TO(SUM(TOBAG(jeem , jeep , jeec )),3) as jresult , cat , dob;
rankjnbres = rank jnbresult1 by jresult DESC , bresult DESC , jeem DESC, math DESC, jeep DESC, phy DESC, jeec DESC, chem DESC, gender ASC, dob ASC, fname ASC, lname ASC DENSE;
rankjnbres1 = rank jnbresult1 by bresult DESC , jeem DESC, math DESC, jeep DESC, phy DESC, jeec DESC, chem DESC, gender ASC, dob ASC, fname ASC, lname ASC DENSE;
allper = foreach rankjnbres generate id, rank_jnbresult1 , fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec, bresult, jresult , cat , dob , ROUND_TO(((double)((10000-rank_jnbresult1)/100.000)),3) as aper;
allper1 = foreach rankjnbres1 generate id, rank_jnbresult1 , fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec, bresult, jresult , cat , dob , ROUND_TO(((double)((10000-rank_jnbresult1)/100.000)),3) as a1per;
SPLIT allper into cbseB if board=='CBSE', anbB if board=='Andhra Pradesh', apB if board=='Arunachal Pradesh', bhB if board=='Bihar', gjB if board=='Gujarat' , jnkB if board=='Jammu and Kashmir', mpB if board=='Madhya Pradesh', mhB if board=='Maharashtra', rjB if board=='Rajasthan' , ngB if board=='Nagaland' , tnB if board=='Tamil Nadu' , wbB if board=='West Bengal' , upB if board=='Uttar Pradesh';
rankcbseB = rank cbseB by jresult DESC , bresult DESC , jeem DESC, math DESC, jeep DESC, phy DESC, jeec DESC, chem DESC, gender ASC, dob ASC, fname ASC, lname ASC DENSE;
grp = group rankcbseB all;
maxno = foreach grp generate MAX(rankcbseB.rank_cbseB) as max1;
cbseper = foreach rankcbseB generate id, rank_cbseB , fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec, bresult, jresult , cat , dob , ROUND_TO(((double)((maxno.max1-rank_cbseB)*100.000/maxno.max1)),3) as per , aper;
rankBcbseB = rank cbseB by bresult DESC , jeem DESC, math DESC, jeep DESC, phy DESC, jeec DESC, chem DESC, gender ASC, dob ASC, fname ASC, lname ASC DENSE;
grp = group rankBcbseB all;
maxno = foreach grp generate MAX(rankBcbseB.rank_cbseB) as max1;
Bcbseper = foreach rankBcbseB generate id, rank_cbseB , fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec, bresult, jresult , cat , dob , ROUND_TO(((double)((maxno.max1-rank_cbseB)*100.000/maxno.max1)),3) as bper , aper;
rankanbB = rank anbB by jresult DESC , bresult DESC , jeem DESC, math DESC, jeep DESC, phy DESC, jeec DESC, chem DESC, gender ASC, dob ASC, fname ASC, lname ASC DENSE;
grp = group rankanbB all;
maxno = foreach grp generate MAX(rankanbB.rank_anbB) as max1;
anbper = foreach rankanbB generate id, rank_anbB , fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec, bresult,jresult , cat , dob , ROUND_TO(((double)((maxno.max1-rank_anbB)*100.000/maxno.max1)),3) as per , aper;
rankBanbB = rank anbB by bresult DESC , jeem DESC, math DESC, jeep DESC, phy DESC, jeec DESC, chem DESC, gender ASC, dob ASC, fname ASC, lname ASC DENSE;
grp = group rankBanbB all;
maxno = foreach grp generate MAX(rankBanbB.rank_anbB) as max1;
Banbper = foreach rankanbB generate id, rank_anbB , fname , lname , board , eid , gender , math , phy , chem , jeem , jeep , jeec, bresult, jresult , cat , dob , ROUND_TO(((double)((maxno.max1-rank_anbB)*100.000/maxno.max1)),3) as bper , aper;
joinall = join cbseper by (per) , Bcbseper by (bper) ;
joinall = foreach joinall generate Bcbseper::id as id,cbseper::jresult as b1;
A = cross Bcbseper , allper;
A1 = foreach A generate Bcbseper::id as id,Bcbseper::rank_cbseB as rank,Bcbseper::fname as fname,Bcbseper::lname as lname,Bcbseper::board as board,Bcbseper::eid as eid ,Bcbseper::gender as gender, Bcbseper::bresult as bresult,Bcbseper::jresult as jresult,Bcbseper::cat as cat,Bcbseper::dob as dob,Bcbseper::bper as bper,Bcbseper::aper as aper,allper::jresult as b2,allper::aper as a1per;
B = filter A1 by bper > a1per;
C = group B by id;
Dcbse = foreach C {
E = order B by a1per DESC;
F = limit E 1;
generate FLATTEN(F.id) , FLATTEN(F.b2);
};
joincbse = join joinall by id , Dcbse by id;
joincbse = foreach joincbse generate joinall::id as id , joinall::b1 as b1, Dcbse::null::b2 as b2;
joinall = join anbper by (per) , Banbper by (bper) ;
joinall = foreach joinall generate Banbper::id as id,anbper::jresult as b1;
A = cross Banbper , allper;
A1 = foreach A generate Banbper::id as id,Banbper::rank_anbB as rank,Banbper::fname as fname,Banbper::lname as lname,Banbper::board as board,Banbper::eid as eid ,Banbper::gender as gender, Banbper::bresult as bresult,Banbper::jresult as jresult,Banbper::cat as cat,Banbper::dob as dob,Banbper::bper as bper,Banbper::aper as aper,allper::jresult as b2,allper::aper as a1per;
B = filter A1 by bper > a1per;
C = group B by id;
Danb = foreach C {
E = order B by a1per DESC;
F = limit E 1;
generate FLATTEN(F.id) , FLATTEN(F.b2);
};
joinanb = join joinall by id , Danb by id;
joinanb = foreach joinanb generate joinall::id as id , joinall::b1 as b1, Danb::null::b2 as b2;
uni_b = UNION joincbse , joinanb ;
I got the solution to this. What is did was the following...
First i stored all the relations A, B, C, .... using store operation as follows
STORE A into into '/opA/' using PigStorage(',');
Then, I Loaded the input for all the relation using load operation as follows
ipA = load '/opA/part-r-00000' USING PigStorage (',') as (id:Biginteger, b1: double, b2: double);
And at last I did the union using the union operation as follows
uni_b = UNION ipA ,ipB ,ipC , ipD ,ipE ;
I got the answer without any error.

while insertind data using insert command it is not working

insert into ra_bdr_msc_telco( Id , accessPointName , balance , bearerService , callForwardNumber , callPartnerExt , callType , calledIMSI , calledNumber , callingIMSI , callingNumber , causeForRecordClosing , cellID , cfwIMSI , cfwNumber , chargeTotal , chargingID , chargingIndicator , dataVolumeDownlink , dataVolumeUplink , dayCode , defaultPriority , duration , endDate , endTime , fileId , filePos , forwardingReason , ggsnAddress , iMEI , incomingRoute , lac , localeID , mcc , mediatedTime , mediationId , mmscSequenceNumber , mnc , msLocation , mscIdentity , netWorkElement , networkID , nodeID , originalCallPartner , outgoingRoute , prePostFlag , priorityLevel , productID , rated , recordSequenceNumber , reserved1 , reserved2 , reserved3 , reserved4 , reserved5 , reserved6 , roam , scpAddress , servedMSISDN , serviceKey , serviceTypeID , smscReferenceNumber , sourceId , startDate , startTime , tariffSwitchInd , teleServiceCode , terminationType , timeZone , volume) values('111222333','NULL','NULL','','NULL','NULL','MO','NULL','96898785034222','413024100494697','776582419','NULL','Hitech City5,'NULL','NULL','NULL','NULL','CallingParty','NULL','NULL','NULL','NULL','32','2012-02-02','13:41:50','b01298689.dat.old','NULL','NULL','NULL','354750040197530','HRAMBA4-BSC','20088','20088','NULL','11/25/14 10:10 PM','','NULL','14F320','NULL','00FF02','MSC','NULL','NULL','NULL','TMGW3H_IP','PREPAID','NULL','NULL','','NULL','NULL','NULL','NULL','NULL','NULL','b01298689','NULL','NULL','1994776582419','NULL','VOICE_IDD','NULL','5','2012-02-02','13:41:18','NULL','11','0','+5:30','NULL');
im trying to insert 69 values for 69 fields..after clicking on enter in the next line it is showing "'> "symbol
You have unclosed quotes near "'Hitech City5,"

Resources