Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I can easily enough find what records are duplicated :
if (peek('Line_ID',-1) = Line_ID ,'Dup','NoDup') as DupRec
But this will only mark the 2nd record, I need to mark the first one as well, ie mark them both as duplicate?
Apologies, not ignoring it, trying to go with the solution I understand better, that's all.
Why don't you try something like:
LOAD
[your original load]
;
LEFT JOIN (Your Original Table)
LOAD
Line_ID,
RangeMin(Count(Line_ID), 1) as DuplicateFlag
RESIDENT
(Your Original Table)
GROUP BY Line_ID;
Not a problem.
Best,
Sunny
The solution is fooling around with a few Resident loads.
Lets assume the table with your original IF statement is called TableTMP.
DoubleTMP:
Mapping
Load Line_ID as DoubleID,
'Dub' as Flag
Resident TableTMP
where DupRec = 'Dub';
That makes a helper list with all the keys that are double.
Next, create your final table:
TableFinal:
NoConcatinate
Load
AllKindOfFieldsFromTableTMP,
applymap('DoubleTMP', Line_ID, 'NotDub') as DupRec
Resident TableTMP
;
Drop Table TableTMP;
I assume it can be done easier, but this should work.
Or yet another solution... count.
countduplicates:
MAPPING LOAD DISTINCT Line_ID,
count(some field) As duplicates
RESIDENT table Group by Line_ID;
finaltable:
LOAD Line_ID,
Applymap('countduplicates',Line_ID,0)
RESIDENT table;
Try This
Load
Line_id,
If(Count(Line_id)>1,'Dup','No_Dup') AS DupRec
Resident Table
Group by Line_id;
Please try
x:
LOAD *Inline [SalesID,SalesAmount
1,100
1,100
1,7
2,200
2,200
3,400
3,400
4,60
5,2000
6,900
];
y:
LOAD SalesID,SalesAmount,
if ((peek('SalesID',-1)= SalesID or peek('SalesID',1)= SalesID),'Dup','NoDup') as DupRec
Resident x
order by SalesID;
drop Table x;