Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm trying to use the "RENAME FIELDS using x;" function to rename fields in my tables, but i'm running into some strange behaviour and I was wondering if someone could explain why this is happening and how best to avoid it? see my code below, you can see it will not rename column "BLAH", but why? |
t_1:
mapping load * inline [
Orig, New
CUSTNO, CustomerNumber
BLAH, CustomerNumber
];
test:
Load * inline [
CUSTNO, Name
1234, James
];
test2:
Load * inline [
BLAH, Name2
1235, Chris
];
RENAME FIELDS using t_1;
That's because the new field name CustomerNumber already exists (edit: at the time of renaming, see previous renaming of CUSTNO), a scenario where you can't use rename fields (this would imply merging the existing fields into a key field, and this is more than just renaming fields).
That's because the new field name CustomerNumber already exists (edit: at the time of renaming, see previous renaming of CUSTNO), a scenario where you can't use rename fields (this would imply merging the existing fields into a key field, and this is more than just renaming fields).
Thanks for your answer I guessed as much. If I wanted these to be renamed and joined as keys-- would this just be an incorrect use of RENAME FIELDS statement. COuld you suggest a way to do this differently, or should it just be hardcoded in there somehow.
AFAIK, you need to create key fields using LOAD statements, i.e. when you are creating the data model.
Key fields don't need a user friendly name in most applications (often they are even hidden from the user using a Hide prefix), so there is seldom a need to rename key fields using a mapping table.
Create the needed links when LOADing your tables by renaming the input table fields using AS, if needed.