Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
I´m with a doubt about a "fiel update".
For example, I have a table:
AGES:
LOAD * INLINE [
NAME, AGE
JOHN, 20
BILL, 25
PAUL, 30
];
CORRECT:
LOAD * INLINE [
NAME, AGE
BILL, 55
];
As result, I want this:
NAME, AGE
JOHN, 20
BILL, 55
PAUL, 30.
What better way to do this ?
Best Regars,
Applymap is your friend here I think:
CORRECT:
Mapping LOAD * INLINE [
NAME, AGE
BILL, 55
];
AGES:
LOAD NAME, applymap('CORRECT',NAME,AGE) as AGE;
LOAD * INLINE [
NAME, AGE
JOHN, 20
BILL, 25
PAUL, 30
];
Just one of multiple ways to do this. Add the following to the end of your script:
CORRECTED_AGES:
LOAD * RESIDENT CORRECT;
CONCATENATE (CORRECTED_AGES)
LOAD * RESIDENT AGES
WHERE NOT EXISTS(NAME);
DROP Table AGES;
RENAME Table CORRECTED_AGES TO AGES;
Best,
Peter
Dear Peter,
I can´t use Resident in this case because I have millions rows.
For this i need a function.
Tks,
Dear Peter,
I can´t use Resident in this case because I have millions rows.
For this i need a function.
Tks,
Applymap is your friend here I think:
CORRECT:
Mapping LOAD * INLINE [
NAME, AGE
BILL, 55
];
AGES:
LOAD NAME, applymap('CORRECT',NAME,AGE) as AGE;
LOAD * INLINE [
NAME, AGE
JOHN, 20
BILL, 25
PAUL, 30
];
Nice one indeed.
Peter
Thanks Gysbert,
Now its my friend hahaha
Best Regards,
As a bonus: keep in mind that a PRECEDING LOAD uses resident tables as well. They're just not that visible.
As a 2nd bonus: ApplyMap is way faster than exists(), especially with lots of data.
Peter
U Can preform Mapping load as its faster than join
CorrectData:
Mapping LOAD
NAME,
AGE INLINE [
NAME, AGE
BILL, 55
];
Data:
Load ApplyMap('CorrectData',NAME,AGE) AS CorrectAge,
NAME;
LOAD * INLINE [
NAME, AGE
JOHN, 20
BILL, 25
PAUL, 30
];